fix: log error description instead of error type for RobotException#1098
Open
z5005z-hue wants to merge 1 commit intoequinor:mainfrom
Open
fix: log error description instead of error type for RobotException#1098z5005z-hue wants to merge 1 commit intoequinor:mainfrom
z5005z-hue wants to merge 1 commit intoequinor:mainfrom
Conversation
Add __str__ method to RobotException base class to return
error_description instead of the default type name representation.
Previously, logging f"{e}" for a RobotException would only show
the exception class name (e.g. 'RobotActionException') rather than
the actual error description message. This makes log messages much
more informative for debugging.
Closes equinor#956
andchiind
requested changes
Feb 24, 2026
Contributor
andchiind
left a comment
There was a problem hiding this comment.
Thank you for your contribution. Can you please edit the commit name to adhere to our standard? Can you call it something like "Log error description instead of error type for RobotException" instead? The PR looks good otherwise, but we don't usually use colons in the commit name.
|
This pull request has been automatically marked as stale due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When catching
RobotException(or its subclasses) and logging withf"{e}", Python's default__str__for exceptions returns the class name rather than a meaningful message, sinceRobotException.__init__doesn't callsuper().__init__().This results in log messages like:
instead of the actual error description.
Fix
Add a
__str__method to theRobotExceptionbase class that returnsself.error_description. This fixes all subclasses automatically.Now the log will show:
Closes #956