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

Fix error shadowing in log when plugin fails to load #1467

Merged

Conversation

gonzalo-bulnes
Copy link
Contributor

Fixes #1466

I don't think this is the ideal handling of the situation, because all log entries would contain two error messages. But I'm opening the PR for discussion.

I didn't find a standard way of unwrapping the error,
short of printing an entire stack trace. I don't think printing
a stack trace in a log is useful, so I decided to print
the error.__cause__ explicitly.

Since there is always one single level of nesting in this code,
I think that's OK.

See https://docs.python.org/3/library/exceptions.html
@pierotofy
Copy link
Member

I think this would be fine, thanks for the PR.

If you want to make it a single error message, you could use:

logger.warning("Failed to instantiate plugin {}: {}".format(dir, e.__cause__ if e.__cause__ is not None else e))

?

@gonzalo-bulnes
Copy link
Contributor Author

I think that's a better option! I'll amend the commit. 👍

@gonzalo-bulnes
Copy link
Contributor Author

gonzalo-bulnes commented Feb 9, 2024

Wait, sorry, no. If the plugin is indeed a core plugin, but an error happens when loading it, then only printing e.__cause__ would remove the relevant error and only keep the attempt at loading the plugin as a non-core plugin, which is not really relevant. (The opposite of the current situation.)

So I think it's probably best to keep both. What do you think @pierotofy ?

@pierotofy
Copy link
Member

Sounds good to me. Thanks!

@pierotofy pierotofy merged commit 206edf1 into OpenDroneMap:master Feb 9, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

Loading errors from non-core plugins don't appear in the webapp log
2 participants