Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Passing errors as second argument #9

Closed
bigluck opened this issue Sep 25, 2015 · 3 comments
Closed

Passing errors as second argument #9

bigluck opened this issue Sep 25, 2015 · 3 comments

Comments

@bigluck
Copy link

bigluck commented Sep 25, 2015

Hi,
I would like to pass errors object as second argument in the class constructor, something like:

return next new app.errors.BadRequest "Invalid fields", name: "Empty value", email: "Invalid email address"

Response:

{
  "code": 400,
  "name": "BadRequest",
  "message": "Invalid fields",
  "errors": {
    "name": "Empty value",
    "email": "Invalid email address"
  }
}

Right now to reproduce this output I have to:

err = new app.errors.BadRequest "Invalid fields"
err.errors = 
  name: "Empty value"
  email: "Invalid email address"
return next err
@ekryski
Copy link
Member

ekryski commented Nov 16, 2015

That seems pretty valid. I'll look to get that in shortly, unless you have a PR handy 😉

@ekryski
Copy link
Member

ekryski commented Nov 30, 2015

We're going to include this in the boiler plate generator and drop the handlers from this repo as described here: #11.

@ekryski
Copy link
Member

ekryski commented Dec 14, 2015

Whenever you create an error you can now pass errors or data as a primary or secondary argument.

For example:

var err1 = new errors.BadRequest('Invalid Fields', {errors: {name: 'Empty Value', email: 'Invalid Email'} });

// or

var err2 = new errors.BadRequest({errors: {name: 'Empty Value', email: 'Invalid Email'} });

@ekryski ekryski closed this as completed Dec 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants