Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Source/buildbindingpython.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,56 @@ func buildDynamicPythonImplementation(componentdefinition ComponentDefinition, w
w.Writeln(" if self._message:")
w.Writeln(" return '%sException ' + str(self._code) + ': '+ str(self._message)", NameSpace)
w.Writeln(" return '%sException ' + str(self._code)", NameSpace)
w.Writeln(" ")
w.Writeln(" def get_error_code(self):")
w.Writeln(" \"\"\"Returns the error code\"\"\"")
w.Writeln(" return self._code")
w.Writeln(" ")
w.Writeln(" def get_error_message(self):")
w.Writeln(" \"\"\"Returns the custom error message\"\"\"")
w.Writeln(" return self._message")
w.Writeln(" ")
w.Writeln(" def get_error_name(self):")
w.Writeln(" \"\"\"Returns the error name (constant name)\"\"\"")
w.Writeln(" if self._code == ErrorCodes.SUCCESS:")
w.Writeln(" return 'SUCCESS'")
for _, errorDef := range componentdefinition.Errors.Errors {
w.Writeln(" elif self._code == ErrorCodes.%s:", errorDef.Name)
w.Writeln(" return '%s'", errorDef.Name)
}
w.Writeln(" else:")
w.Writeln(" return 'UNKNOWN'")
w.Writeln(" ")
w.Writeln(" def get_error_description(self):")
w.Writeln(" \"\"\"Returns the error description (human-readable)\"\"\"")
w.Writeln(" if self._code == ErrorCodes.SUCCESS:")
w.Writeln(" return 'success'")
for _, errorDef := range componentdefinition.Errors.Errors {
w.Writeln(" elif self._code == ErrorCodes.%s:", errorDef.Name)
w.Writeln(" return '%s'", errorDef.Description)
}
w.Writeln(" else:")
w.Writeln(" return 'unknown error'")
w.Writeln(" ")
w.Writeln(" @property")
w.Writeln(" def error_code(self):")
w.Writeln(" \"\"\"Property to access error code\"\"\"")
w.Writeln(" return self._code")
w.Writeln(" ")
w.Writeln(" @property")
w.Writeln(" def error_message(self):")
w.Writeln(" \"\"\"Property to access custom error message\"\"\"")
w.Writeln(" return self._message")
w.Writeln(" ")
w.Writeln(" @property")
w.Writeln(" def error_name(self):")
w.Writeln(" \"\"\"Property to access error name\"\"\"")
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()")
Comment on lines +179 to +184
Copy link
Preview

Copilot AI Oct 7, 2025

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.

Suggested change
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.

w.Writeln("")


Expand Down
Loading