Skip to content

Commit

Permalink
feat: add __str__ methods for error objects
Browse files Browse the repository at this point in the history
  • Loading branch information
drstrangelooker committed Mar 8, 2024
1 parent a80f140 commit e264d2d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions python/looker_sdk/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ErrorDetail:
field: field with error
code: error code
message: error info message
error_doc_url: URL that may point to additional useful information
error_doc: Markdown doc that may contain additional useful information
"""

documentation_url: str
Expand All @@ -46,13 +48,25 @@ class ErrorDetail:
error_doc_url: str = ""
error_doc: str = ""

def __str__(self):
return f"""
*****
documentation_url: {self.documentation_url}
field: {self.field}
code: {self.code}
message: {self.message}
error_doc_url: {self.error_doc_url}
"""


@attr.s(auto_attribs=True)
class SDKError(Exception):
"""API error class:
message: main error info message
errors: array of error details
documentation_url: documentation link
error_doc_url: URL that may point to additional useful information
error_doc: Markdown doc that may contain additional useful information
"""

message: str
Expand All @@ -61,6 +75,16 @@ class SDKError(Exception):
error_doc_url: str = ""
error_doc: str = ""

def __str__(self):
sep = "****\n"
return f"""
message: {self.message}
documentation_url: {self.documentation_url}
error_doc_url: {self.error_doc_url}
error details:
{sep.join(self.errors)}
"""


"""Error Doc Helper class
"""
Expand Down

0 comments on commit e264d2d

Please sign in to comment.