Skip to content

fix: log error description instead of error type for RobotException#1098

Open
z5005z-hue wants to merge 1 commit intoequinor:mainfrom
z5005z-hue:fix/robot-exception-str
Open

fix: log error description instead of error type for RobotException#1098
z5005z-hue wants to merge 1 commit intoequinor:mainfrom
z5005z-hue:fix/robot-exception-str

Conversation

@z5005z-hue
Copy link
Copy Markdown

Problem

When catching RobotException (or its subclasses) and logging with f"{e}", Python's default __str__ for exceptions returns the class name rather than a meaningful message, since RobotException.__init__ doesn't call super().__init__().

This results in log messages like:

Failed to retrieve robot status: RobotActionException

instead of the actual error description.

Fix

Add a __str__ method to the RobotException base class that returns self.error_description. This fixes all subclasses automatically.

Now the log will show:

Failed to retrieve robot status: <actual error description>

Closes #956

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
Copy link
Copy Markdown
Contributor

@andchiind andchiind left a comment

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.

@github-actions github-actions bot added the stale This issue or pull request already exists label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logs error message type instead of description

2 participants