Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions quickbooks/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,57 @@ def __init__(self, message, error_code=0, detail=""):
self.error_code = error_code
self.detail = detail
self.message = message

def __str__(self) -> str:
return f"QB Exception {self.error_code}: {self.message}\n{self.detail}"
def __iter__(self):
yield "error_code", self.error_code
yield "detail", self.detail
yield "message", self.message

class AuthorizationException(QuickbooksException):
"""
Quickbooks Error Codes from 1 to 499
"""
def __str__(self):
return "QB Auth Exception: " + self.message + " \n\n" + self.detail
return f"QB Auth Exception {self.error_code}: {self.message}\n{self.detail}"


class UnsupportedException(QuickbooksException):
"""
Quickbooks Error Codes from 500 to 599
"""
def __str__(self):
return "QB Unsupported Exception: " + self.message + " \n\n" + self.detail
return f"QB Unsupported Exception {self.error_code}: {self.message}\n{self.detail}"


class GeneralException(QuickbooksException):
"""
Quickbooks Error Codes from 600 to 1999
"""
def __str__(self):
return "QB General Exception: " + self.message + " \n\n" + self.detail
return f"QB General Exception {self.error_code}: {self.message}\n{self.detail}"


class ValidationException(QuickbooksException):
"""
Quickbooks Error Codes from 2000 to 4999
"""
def __str__(self):
return "QB Validation Exception: " + self.message + " \n\n" + self.detail
return f"QB Validation Exception {self.error_code}: {self.message}\n{self.detail}"


class SevereException(QuickbooksException):
"""
Quickbooks Error Codes greater than 10000
"""
def __str__(self):
return "QB Severe Exception: " + self.message + " \n\n" + self.detail
return f"QB Severe Exception {self.error_code}: {self.message}\n{self.detail}"


class ObjectNotFoundException(QuickbooksException):
"""
Quickbooks Error Code 610
"""
def __str__(self):
return "QB Object Not Found Exception: " + self.message + " \n\n" + self.detail
return f"QB Object Not Found Exception {self.error_code}: {self.message}\n{self.detail}"