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

Better exception handling #40

Open
Razikus opened this issue Apr 14, 2022 · 1 comment
Open

Better exception handling #40

Razikus opened this issue Apr 14, 2022 · 1 comment

Comments

@Razikus
Copy link
Collaborator

Razikus commented Apr 14, 2022

Currently there is no way to get matching error code from error exception.

From my investigation:

This exception have mainly 3 "normal" fields now

debug_error_string {"created":"@1649922703.326925387","description":"Error received from peer ipv6:[::1]:3322","file":"src/core/lib/surface/call.cc","file_line":903,"grpc_message":"invalid user name or password","grpc_status":2}

details invalid user name or password

code StatusCode.UNKNOWN - it matches internal codes from GRPC, and not the code provided by server (08004)

Or in some cases
https://github.com/codenotary/immudb/blob/master/pkg/errors/map.go

I looked depper into it and i see that the proper status code is in some unparsed trailing_metadata field
(_Metadatum(key='grpc-status-details-bin', value=b'\x08\x02\x12\x1dinvalid user name or password\x1aE\n+type.googleapis.com/immudb.schema.ErrorInfo\x12\x16\n\x0508004\x12\rkey not found\x1a-\n+type.googleapis.com/immudb.schema.RetryInfo'),)

.....schema.ErrorInfo\x12\x16\n\x05------->08004<-------\x12\rkey not found\x1a-\n+type.google......

User should have easy way to catch errors and don't compare them to string by himself.
SDK should also have some generic way to deal with Exceptions, or at least map existing error codes

https://github.com/codenotary/immudb/blob/master/pkg/errors/meta.go

@mabmayer
Copy link
Contributor

+1

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

No branches or pull requests

2 participants