Skip to content
This repository was archived by the owner on Sep 28, 2024. It is now read-only.

Repository files navigation

Elefrant Custom Errors

wercker status

Dependency Status

Extend elefrant errors and create your own type of errors.

Install

$ elefrant install elefrant-custom-errors

Usage

Activate the component.

Create your own type of error. Add the new type in lib/errors.js from the component folder.

functionMyNewError(message){restify.RestError.call(this,{restCode: 'MyNewError',statusCode: 418,message: message,constructorOpt: MyNewError});}registerError(restify,'RestError',MyNewError,'MyNewError');

Extra

###Orm

Format ORM errors and validation.

Add to models a new attribute validationMessages:

...
attributes: {name: {type: 'string',required: true,unique: true,index: true}},
...
validationMessages : {name: {required: 'Name is required',}}...

And then usage in controller:

next(newrestify.OrmError(error,MyModel.validationMessages));```
## LicenseMIT©[Elefrant](http://elefrant.com/#/license)

About

Extend elefrant errors with your own type of errors.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages