-
Notifications
You must be signed in to change notification settings - Fork 27
Add getter methods of the python exception class #230
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
base: develop
Are you sure you want to change the base?
Conversation
For example, C++
The python should also have the similiar way:
|
The code and message should be able to return. It keeps consistent with the API of C++. The naming conversion is also followed with ACT implementation rather than python PEP 8.
88540b0
to
ae3285b
Compare
The other language also has the issue, like Java. |
It ensures Cross-Language Consistency. C++: Uses methods (getErrorCode()) C#: Uses properties (ErrorCode) Java: Uses methods (getErrorCode()) Python: Can support both patterns Meanwhile, rename the methods to comply with PEP 8
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.
Pull Request Overview
This PR adds getter methods and properties to the Python exception class to provide consistent access to error information. The implementation aligns with C++ API patterns and follows Python PEP 8 naming conventions.
Key changes:
- Added getter methods (
get_error_code
,get_error_message
,get_error_name
,get_error_description
) - Added corresponding properties (
error_code
,error_message
,error_name
,error_description
) - Implemented logic to map error codes to names and descriptions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
w.Writeln(" return self.get_error_name()") | ||
w.Writeln(" ") | ||
w.Writeln(" @property") | ||
w.Writeln(" def error_description(self):") | ||
w.Writeln(" \"\"\"Property to access error description\"\"\"") | ||
w.Writeln(" return self.get_error_description()") |
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.
The properties error_name
and error_description
add unnecessary indirection by calling getter methods that contain the actual logic. Consider implementing the logic directly in the properties to eliminate the redundant method calls and simplify the code structure.
w.Writeln(" return self.get_error_name()") | |
w.Writeln(" ") | |
w.Writeln(" @property") | |
w.Writeln(" def error_description(self):") | |
w.Writeln(" \"\"\"Property to access error description\"\"\"") | |
w.Writeln(" return self.get_error_description()") | |
w.Writeln(" # Inlined logic from get_error_name") | |
w.Writeln(" return type(self).__name__") | |
w.Writeln(" ") | |
w.Writeln(" @property") | |
w.Writeln(" def error_description(self):") | |
w.Writeln(" \"\"\"Property to access error description\"\"\"") | |
w.Writeln(" # Inlined logic from get_error_description") | |
w.Writeln(" return str(self)") |
Copilot uses AI. Check for mistakes.
The code and message should be able to return. It keeps consistent with the API of C++. The naming conversion is also followed with python PEP 8.