-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Build: Fix exceptions #10616
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
Build: Fix exceptions #10616
Conversation
We were passing the path to the constructor, but that argument is actually the message. The message is already defined in the exception itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were passing the path to the constructor, but that argument is actually the message.
What about checking the message=
type is string in the initializer?
readthedocs.org/readthedocs/doc_builder/exceptions.py
Lines 9 to 19 in bbb200b
class BuildBaseException(Exception): | |
message = None | |
status_code = None | |
def __init__(self, message=None, **kwargs): | |
self.status_code = kwargs.pop( | |
'status_code', | |
None, | |
) or self.status_code or 1 | |
self.message = message or self.message or self.get_default_message() | |
super().__init__(message, **kwargs) |
Or, cast it into string?
I'm thinking about a way to avoid this issue since we've hit long time ago and it was hard to track. I remember talking to Anthony about this and we weren't able to figure it out what was happening.
Co-authored-by: Manuel Kaufmann <[email protected]>
Do you mean raising an exception if the type is incorrect? I'm +1 on that instead of casting, since looks like most of the time, passing that argument to exceptions that have an already defined default message is a mistake. |
Didn't find any other exceptions where we were overriding the default message like this. |
We were passing the path to the constructor,
but that argument is actually the message.
The message is already defined in the exception itself.
Fixes #10538