Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracts classes bases with module names and self name, add them to tags #61

Merged
merged 5 commits into from
Apr 30, 2021

Conversation

kompotkot
Copy link
Contributor

It solves issue #56

@kompotkot kompotkot requested a review from a team April 27, 2021 11:29
@@ -87,6 +87,20 @@ def __init__(
self.is_excepthook_set = False
self.is_loggerhook_set = False

def _extract_error_base(self, error: Exception) -> List[str]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the core functionality we require - this can be an optional parameter in error_report - in case a user wants to add a tag with exception base classes.

You should modify this function to return exception base classes up to a fixed recursion depth - some projects can have complicated exception class hierarchies.

Might be good to use error_type: type instead of error: Exception. You can do everything you need with the class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might use this in the future. I suggest tagging this commit so that we can cherry pick into future work.


error_bases = self._extract_error_base(error=error)
for error_base in error_bases:
tags.append("error:{}".format(error_base))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the base class of hte exception here. I suggest you do:
tags.extend(["error:{}".format(error.__class__.name), "error:{}.{}".format(error.__module__, error.__class__.__name__)])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can skip the first item (without __module__) if it makes sense.

tags.extend(["type:error", "error:{}".format(error.__class__.__name__)])
try:
tags.append(
"moduleerror:{}.{}".format(error.__module__, error.__class__.__name__),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error:full:PersonalException?

Copy link
Member

@zomglings zomglings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zomglings zomglings merged commit 3c93ece into bugout-dev:main Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants