Update API Error Codes
API Error Codes
Description
Currently the Sia API uses 404
for the majority of API calls. In general the Sia API is REST-like but not a strictly RESTful API. As Sia and the API expands there are more and more opportunities to use additional error codes to handle certain events.
Below is the start of a discussion of how to begin to update the default error behavior of the API. More discussion is needed but a standard should be established and documented.
Original Issue Discussion
The following discussion from !4399 (merged) should be addressed:
-
@ChrisSchinnerl started a discussion: (+1 comment) Should we really rely on 404 errors to determine whether the module is loaded or not? It's commonly used for resources which can't be found. e.g. downloading a snaffle that doesn't exist should return
ErrNotFound
.Instead we could change the API to return a more suitable and specific error like:
218 -
This is fine
420 -Enhance your Calm
or more appropriate codes since server errors usually start with 5
501 -
Not implemented
503 -Service unavailable
or probably the best solution would be to reserve one of the non std codes like e.g. Cloudflare does starting at 520.
530 -
ErrModuleNotLoaded