Comments (5)
What do you mean exactly? A new kind of "standard" error to be returned by the methods of this interface for instance? If you return other errors than ones defined in the doc, it will just generate a 520 response with the error's message as description (see https://github.com/rs/rest-layer/blob/master/rest/errors.go#L46). Would you prefer a specific handling for general DB failure?
I'd like to keep this interface as generic as possible. A Storer implementation may not be backed by a DB.
from rest-layer.
I typically return a 502 for backend system errors. To me, that's more accurate than an 520 with a paradoxical error string. I didn't notice the catch-all error handling until you pointed it out, and that certainly will address my issue.
That said, I would be happy to see a new standard error in errors.go that mapped to 502. In the case where the Storer isn't backed by a different service, one could stick with the 520. Thoughts?
from rest-layer.
But how is a 502 (bad gateway) relevant for such an error?
from rest-layer.
By liberally interpreting the API server as a proxy/gateway to the database :-) Interestingly, the only significant reference I found to handling errors from a backend database system comes from here: http://restcookbook.com/HTTP%20Methods/400-vs-500/. They suggest using a 500 or 503 depending on the nature of the problem.
In any case, after I thought about it a while, I'd say that consistency with the Eve project trumps the specific generic error code in my mind. I haven't done any coding with it yet, but hope to use both projects to provide consistent APIs across all of our service.
Please close this ticket unless you think there is more to explore, and thanks for your quick dialogue.
from rest-layer.
The Eve compat is actually not a reason here, I didn't try to make it Eve compatible, just inspired by Eve. The default API output isn't compatible with Eve anyway. I just get all the good ideas from Eve :)
Ok to close, we may think about making this "customizable" in the future if it become a concern for several people.
Thanks for you feedback!
from rest-layer.
Related Issues (20)
- Remove old sub-resource syntax HOT 4
- go module: cannot find module providing package testing/mem HOT 3
- Explicit $eq in filter passes whole predicate to Validate(Query) HOT 3
- OnInsert/OnUpdate hooks can modify the new resource item, Etag not recalculated HOT 7
- `Prefer: return=minimal` can hide resource item on server modification HOT 12
- Consistent empty / null fields HOT 4
- Remove resource hooks in favor of resource middleware HOT 12
- Newest `zerolog` versions cause a panic HOT 4
- Bogus error line, when returning empty response on 204
- Etag should not depend on external state HOT 4
- Assist AutoIncrement FieldValidator with SQL backend HOT 8
- How use schema and resource package as standalone HOT 1
- Bulk PATCH support HOT 5
- Wrapping original issue in rest.Error HOT 7
- Feature Request: Cursor-based Pagination HOT 3
- pq: operator does not exist: uuid ~~ unknown HOT 7
- Filter on reference fields HOT 1
- Support for $not filter operation HOT 4
- Decouple ElemMatch from schema.Array struct
- openapi 3.1.0 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-layer.