forked from hhursev/recipe-scrapers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_exceptions.py
44 lines (31 loc) · 1.34 KB
/
_exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# mypy: disallow_untyped_defs=False
class RecipeScrapersExceptions(Exception):
def __init__(self, message):
self.message = message
super().__init__(message)
def __str__(self):
return f"recipe-scrapers exception: {self.message}"
class WebsiteNotImplementedError(RecipeScrapersExceptions):
"""Error when website is not supported by this library."""
def __init__(self, domain):
self.domain = domain
message = f"Website ({self.domain}) not supported."
super().__init__(message)
class NoSchemaFoundInWildMode(RecipeScrapersExceptions):
"""The scraper was unable to locate schema.org metadata within the webpage."""
def __init__(self, url):
self.url = url
message = f"No Recipe Schema found at {self.url}."
super().__init__(message)
class ElementNotFoundInHtml(RecipeScrapersExceptions):
"""Error when we cannot locate the HTML element on the page"""
def __init__(self, element):
self.element = element
message = (
"Element not found in html (self.soup.find returned None). Check traceback."
)
super().__init__(message)
class SchemaOrgException(RecipeScrapersExceptions):
"""Error in parsing or missing portion of the Schema.org data on the page"""
def __init__(self, message):
super().__init__(message)