Skip to content
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

Centralized Error Management in naas-models #29

Open
Dr0p42 opened this issue Jul 9, 2024 · 0 comments
Open

Centralized Error Management in naas-models #29

Dr0p42 opened this issue Jul 9, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Dr0p42
Copy link
Contributor

Dr0p42 commented Jul 9, 2024

Centralized Error Management in naas-models

Problem Description

Currently, each proto file in the naas-models repository manages its own set of error codes on domain-specific logic. This decentralized approach to error management introduces several issues:

  1. Error Code Overlaps: Each proto file creates error codes independently, leading to overlaps. For example, multiple proto files may define an error code with the value 0, 1, 2, etc.
  2. Complex Error Handling: When combining functionalities from different domains, the overlapping error codes make it difficult to determine the source and nature of an error.
  3. Inconsistent Error Reporting: Handling errors consistently across the client application becomes challenging, as different domains have their own error definitions.

Proposed Solution

To address these issues, we propose creating a centralized errors.proto file that will define a common set of error codes. This file will include a simple enum that encompasses every error code that the application could raise. By using a unified error code system, we can ensure:

  1. Unique Error Codes: Each error code will be unique, avoiding overlaps.
  2. Simplified Error Handling: A single source of truth for error codes will make it easier to track and handle errors in the application and client-side.
  3. Consistent Error Reporting: Errors can be reported consistently across different domains and services.

Example Enum

enum Errors {
    NO_ERROR = 0;
    WORKSPACE__ALREADY_EXISTS = 1;
    WORKSPACE__NOT_FOUND = 2;
    WORKSPACE__NOT_UPDATED = 3;
    WORKSPACE__NOT_AUTHORIZED = 4;
    AIMODEL__OUT_OF_CREDITS = 5;
    AIMODEL__DONT_HANDLE_COMPLETION = 6;
}

Action Items

  1. Create errors.proto File: Define a centralized errors.proto file that includes common error codes.
  2. Update Existing Proto Files: Refactor existing proto files to use the centralized error codes from the new errors.proto.
  3. Modify Error Handling Logic Update the application logic to utilize the centralized error codes, ensuring consistent error handling and reporting.
  4. Client Application Updates: Ensure that the client application is adapted to handle the new centralized error codes.

Benefits

  • Improved Maintainability: Centralized error management simplifies future changes and additions to error codes.
  • Enhanced Debugging: Easier to identify and debug errors due to unique and consistent error codes.
  • Reduced Complexity: Simplifies the interaction between different domains and services by providing a unified error handling mechanism.

Conclusion

By centralizing error management in a dedicated errors.proto file, we can resolve the current issues related to overlapping error codes and inconsistent error reporting. This approach will lead to a more maintainable, debuggable, and user-friendly error handling system across the naas-models repository.


Please review and provide feedback or approval for implementing this change.

@Dr0p42 Dr0p42 added the enhancement New feature or request label Jul 9, 2024
@Dr0p42 Dr0p42 self-assigned this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant