Skip to content

Conversation

spywo
Copy link

@spywo spywo commented Oct 2, 2025

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.

@spywo
Copy link
Author

spywo commented Oct 2, 2025

For example, C++

try {}
catch (const AdProjectionSystem::EAdProjectionSystemException& e) {
    // Handle error with code and message
    auto errorCode = e.getErrorCode();
    auto errorMessage = e.getErrorMessage();
    
    if (errorCode == ADPROJECTIONSYSTEM_ERROR_CRS_NOT_FOUND) {
        // Provide localized message or fallback behavior
    }
}

The python should also have the similiar way:

try:
except AdProjectionSystem.EAdProjectionSystemException as e:
    error_code = e.GetErrorCode()
    error_message = e.GetErrorMessage()
    
    # Use error code for localization or display message directly
    handle_error(error_code, error_message)

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.
@spywo spywo force-pushed the oliver/python/exception-getter branch from 88540b0 to ae3285b Compare October 2, 2025 19:50
@spywo
Copy link
Author

spywo commented Oct 2, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant