-
Notifications
You must be signed in to change notification settings - Fork 1
/
exceptions.py
39 lines (23 loc) · 943 Bytes
/
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
class APIError(Exception):
"""All custom API Exceptions"""
pass
class ParserNotFoundError(APIError):
"""Error when a valid parser is not found."""
code = 404
description = "Parser not found."
class UnusualTrafficError(APIError):
"""Error when article source states "unusual traffic from your account" rather than author data."""
code = 403
description = "Unusual traffic error."
class S3FileNotFoundError(APIError):
"""Error when file does not exist in S3."""
code = 404
description = "Source file not found on S3. Nothing to parse."
class BadLandingPageError(APIError):
code = 400
description = "Bad landing page contents. No data available to parse."
class WrongFormatLandingPageError(APIError):
def __init__(self, format_):
self.format_ = format_
self.description = f'Wrong format landing page ({self.format_} format). Unable to parse.'
code = 400