Compatibility
Compatible with Meteor 2.4 and Meteor 3.0
This repository provides versions for the package simple:rest-json-error-handler that are compatible with latest Meteor. This is necessary because the author is not maintaining package anymore.
Changes
- v1.1.3
- Relaxed
simple:json-routes
dependency to includev3.0.0
. api.versionsFrom
onPackage.onUse
includes Meteor version3.0
.
- Relaxed
- v1.1.1
- Update simple:json-routes to 2.3.0
- v1.1.0
api.versionsFrom
onPackage.onUse
was changed from1.0
to2.4
.
simple:rest-json-error-handler
SimpleRest error middleware for converting thrown Meteor.Errors to JSON and sending the response.
Usage
Handle errors from all routes:
1JsonRoutes.ErrorMiddleware.use(RestMiddleware.handleErrorAsJson);
Handle errors from one route:
1JsonRoutes.ErrorMiddleware.use( 2 '/handle-error', 3 RestMiddleware.handleErrorAsJson 4);
Example
1JsonRoutes.ErrorMiddleware.use( 2 '/handle-error', 3 RestMiddleware.handleErrorAsJson 4); 5 6JsonRoutes.add('get', 'handle-error', function () { 7 var error = new Meteor.Error('not-found', 'Not Found'); 8 error.statusCode = 404; 9 throw error; 10});