-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathexceptions.py
More file actions
69 lines (48 loc) · 1.69 KB
/
exceptions.py
File metadata and controls
69 lines (48 loc) · 1.69 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class DjangoAfipException(Exception):
"""Superclass for all exceptions explicitly thrown by this app."""
class AfipException(DjangoAfipException):
"""
Wraps around errors returned by AFIP's WS.
"""
def __init__(self, response):
if "Errors" in response:
message = "Error {}: {}".format(
response.Errors.Err[0].Code,
response.Errors.Err[0].Msg,
)
else:
message = "Error {}: {}".format(
response.errorConstancia.idPersona,
response.errorConstancia.error[0],
)
Exception.__init__(self, message)
class AuthenticationError(DjangoAfipException):
"""
Raised when there is a non-specific error during an authentication attempt.
"""
pass
class CertificateExpired(AuthenticationError):
"""
Raised when an authentication was attempted with an expired certificate.
"""
pass
class UntrustedCertificate(AuthenticationError):
"""
Raise when an untrusted certificate is used in an authentication attempt.
"""
pass
class CorruptCertificate(AuthenticationError):
"""
Raised when a corrupt ceritificate file is used in an authenticaiton
attempt.
"""
pass
class CannotValidateTogether(DjangoAfipException):
"""
Raised when attempting to validate receipts that cannot be validated
together (eg: different receipt types, or different point of sales).
"""
class ValidationError(DjangoAfipException):
"""Raised when a single Receipt failed to validate with AFIP's WS."""
class CaeaCountError(DjangoAfipException):
"""Raised when query the caea to obtain the number but 0 or 2 or more."""