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

honeybadger.notify: error_message is ignored when an exception is provided #187

Open
benjaoming opened this issue Jan 8, 2025 · 5 comments
Assignees

Comments

@benjaoming
Copy link
Contributor

Say I want to use a pattern like this:

try:
    launch_rocket(*args)
except Exception as e:
    handle_failure()
    honeybadger.notify(
        error_message=f"Failed to launch rocket: {str(args)}",
        exception=e,
        context={
            "retries": retries,
        },
    )

...then what I get is a correct exception traceback. But the error_message argument isn't found.

image

@stympy
Copy link
Member

stympy commented Jan 8, 2025

Hey @benjaoming — thanks for opening the issue! What you observed is by design... if you provide an exception to notify, the library uses str(exception) to populate the Message field and ignores the error_message argument. I recommend doing something like this:

try:
    launch_rocket(*args)
except Exception as e:
    handle_failure()
    honeybadger.notify(
        exception=e,
        context={
            "retries": retries,
            "args": str(args),  # Add launch args as context instead
        },
    )

@stympy stympy closed this as completed Jan 8, 2025
@benjaoming
Copy link
Contributor Author

@stympy understood, but it's a bit confusing that it will happily accept the argument and throw away the data. Not sure what's a good solution, certainly failing the call doesn't seem nice. But maybe automatically adding it to the context would help the misguided dev 😄

@benjaoming
Copy link
Contributor Author

And thanks for the quick response 🙏

@stympy
Copy link
Member

stympy commented Jan 8, 2025

Yeah, I agree that's not a great experience... I like the idea of adding it to the context.

@subzero10
Copy link
Member

I'm re-opening the issue to add the error_message to the context when both an error_message and exception are provided.

@subzero10 subzero10 reopened this Jan 21, 2025
@subzero10 subzero10 self-assigned this Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants