Rowno/node-rip — Issue #11: Implement error handling
Author: Rowno
Created: 2012-02-04 12:55:27+00:00
State: open
Labels: feature

Create a way to gracefully handle API errors and return descriptive error information to the client. The main use case for this would be for errors caused in middleware, but could also be used for the actual endpoint methods. There would need to be a way to trigger an error and a way to register an error handler that takes in the error information and formats an error response. There would also need to be a form of middleware for the error response to be able apply data filters.

Ways to trigger errors could be to provide an `error` method to all callbacks or to catch exceptions thrown from callbacks.

Ways of registering error handlers could be to make the Api object an event emitter, add a method to the Api object to register error handlers or put the error handlers in the api endpoint modules. Multiple error handlers could be handled in a way similar to the middleware (like Express).