Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Add Error Codes to Errors #545

Open
jjeffryes opened this issue Jun 19, 2017 · 4 comments
Open

Add Error Codes to Errors #545

jjeffryes opened this issue Jun 19, 2017 · 4 comments
Labels
feature Feature or enhancement to openbazaar-go

Comments

@jjeffryes
Copy link
Collaborator

jjeffryes commented Jun 19, 2017

To make server errors easier for the users to understand, and to make it possible to provide translations for them, add an error code field to each error.

The proposed format is:

{
    "success": false,
    "reason": "failed to find any peer in table",
    "errorCode": "1234",
}

This would allow clients and scripts without a mapping of the codes to use the reason text, while clients with translations could use the code to show a translated text.

EDIT: as Rob reminded me, the errorCodes should be unique, and the same number should never be used for more than one error code, as it will be mapped directly to a translation string.

@rmisio
Copy link
Collaborator

rmisio commented Jun 19, 2017

Ideally, the errorCode would be unique app-wide.

@jjeffryes
Copy link
Collaborator Author

Ideally, the errorCode would be unique app-wide.

I think that's a hard requirement.

@cpacia
Copy link
Member

cpacia commented Jun 26, 2017

This would be a major under taking as there are literally an unknown number of errors that can be returned because it will pass the error message from lower level libs.

It would need to convert every error from a lib into a more generic message which might be less useful for debugging.

@cpacia cpacia added the feature Feature or enhancement to openbazaar-go label Jun 26, 2017
@jjeffryes
Copy link
Collaborator Author

This would be a major under taking as there are literally an unknown number of errors that can be returned because it will pass the error message from lower level libs.

That's understood. We still need to do it. If we can think of a more efficient way to do it, that would be useful.

It would need to convert every error from a lib into a more generic message which might be less useful for debugging.

I think that's a misunderstanding. The original error message would be maintained, we'd just add an error code to the json returned, in addition to the original error message, as outlined in the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature or enhancement to openbazaar-go
Projects
None yet
Development

No branches or pull requests

5 participants