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

Provide detailed error codes for enhancing error handling from Client #922

Closed
hackerwins opened this issue Jul 8, 2024 · 0 comments
Closed
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers sdk ⚒️

Comments

@hackerwins
Copy link
Member

hackerwins commented Jul 8, 2024

What would you like to be added:

Currently, the server sends Error Code to the client to indicate error code, such as FailedPrecondition, in a simplistic manner. This makes it challenging for clients to differentiate and handle individual situations effectively.

  • // InvalidArgument means the request is malformed.
    converter.ErrPackRequired: connect.CodeInvalidArgument,
    converter.ErrCheckpointRequired: connect.CodeInvalidArgument,
    time.ErrInvalidHexString: connect.CodeInvalidArgument,
    time.ErrInvalidActorID: connect.CodeInvalidArgument,
    types.ErrInvalidID: connect.CodeInvalidArgument,
    clients.ErrInvalidClientID: connect.CodeInvalidArgument,
    clients.ErrInvalidClientKey: connect.CodeInvalidArgument,
    key.ErrInvalidKey: connect.CodeInvalidArgument,
    types.ErrEmptyProjectFields: connect.CodeInvalidArgument,
    // NotFound means the requested resource does not exist.
    database.ErrProjectNotFound: connect.CodeNotFound,
    database.ErrClientNotFound: connect.CodeNotFound,
    database.ErrDocumentNotFound: connect.CodeNotFound,
    database.ErrUserNotFound: connect.CodeNotFound,
    // AlreadyExists means the requested resource already exists.
    database.ErrProjectAlreadyExists: connect.CodeAlreadyExists,
    database.ErrProjectNameAlreadyExists: connect.CodeAlreadyExists,
    database.ErrUserAlreadyExists: connect.CodeAlreadyExists,
    // FailedPrecondition means the request is rejected because the state of the
    // system is not the desired state.
    database.ErrClientNotActivated: connect.CodeFailedPrecondition,
    database.ErrDocumentNotAttached: connect.CodeFailedPrecondition,
    database.ErrDocumentAlreadyAttached: connect.CodeFailedPrecondition,
    database.ErrDocumentAlreadyDetached: connect.CodeFailedPrecondition,
    documents.ErrDocumentAttached: connect.CodeFailedPrecondition,
    packs.ErrInvalidServerSeq: connect.CodeFailedPrecondition,
    database.ErrConflictOnUpdate: connect.CodeFailedPrecondition,
    // Unimplemented means the server does not implement the functionality.
    converter.ErrUnsupportedOperation: connect.CodeUnimplemented,
    converter.ErrUnsupportedElement: connect.CodeUnimplemented,
    converter.ErrUnsupportedEventType: connect.CodeUnimplemented,
    converter.ErrUnsupportedValueType: connect.CodeUnimplemented,
    converter.ErrUnsupportedCounterType: connect.CodeUnimplemented,
    // Unauthenticated means the request does not have valid authentication
    auth.ErrNotAllowed: connect.CodeUnauthenticated,
    auth.ErrUnexpectedStatusCode: connect.CodeUnauthenticated,
    auth.ErrWebhookTimeout: connect.CodeUnauthenticated,
    database.ErrMismatchedPassword: connect.CodeUnauthenticated,

It is necessary to directly transmit error codes generated by the server to allow clients to respond accordingly to each specific error. After transmitting the error codes, each error case needs to be handled individually by clients.

Why is this needed:

To improve client-side error handling and responsiveness to server-generated errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers sdk ⚒️
Projects
No open projects
Status: Done
Development

No branches or pull requests

1 participant