Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/bs4/exceptions.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1"""Exceptions defined by Beautiful Soup itself.""" 

2 

3from typing import Union 

4 

5 

6class StopParsing(Exception): 

7 """Exception raised by a TreeBuilder if it's unable to continue parsing.""" 

8 

9 

10class FeatureNotFound(ValueError): 

11 """Exception raised by the BeautifulSoup constructor if no parser with the 

12 requested features is found. 

13 """ 

14 

15 

16class ParserRejectedMarkup(Exception): 

17 """An Exception to be raised when the underlying parser simply 

18 refuses to parse the given markup. 

19 """ 

20 

21 def __init__(self, message_or_exception: Union[str, Exception]): 

22 """Explain why the parser rejected the given markup, either 

23 with a textual explanation or another exception. 

24 """ 

25 if isinstance(message_or_exception, Exception): 

26 e = message_or_exception 

27 message_or_exception = "%s: %s" % (e.__class__.__name__, str(e)) 

28 super(ParserRejectedMarkup, self).__init__(message_or_exception)