File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change 2020
2121module . exports = function negotiate ( err ) {
2222
23- // Get access to response object (`res`)
2423 var res = this . res ;
24+ var statusCode = err . status || 500 ;
2525
26- var statusCode = 500 ;
27- var body = err ;
28-
29- try {
30-
31- statusCode = err . status || 500 ;
32-
33- // Set the status
34- // (should be taken care of by res.* methods, but this sets a default just in case)
35- res . status ( statusCode ) ;
36-
37- } catch ( e ) { }
26+ res . status ( statusCode ) ;
3827
3928 // Respond using the appropriate custom response
40- if ( statusCode === 403 ) return res . forbidden ( body ) ;
41- if ( statusCode === 404 ) return res . notFound ( body ) ;
29+ if ( statusCode === 403 ) return res . forbidden ( err ) ;
30+ if ( statusCode === 404 ) return res . notFound ( err ) ;
4231
43- console . log ( body ) ;
4432 // This check is specific to sails-json-api-blueprints
45- if ( statusCode === 400 && err . code === "E_VALIDATION" ) return res . invalid ( body ) ;
33+ if ( statusCode === 400 && err . code === "E_VALIDATION" ) return res . invalid ( err ) ;
34+ if ( statusCode === 400 ) return res . badRequest ( err ) ;
4635
47- if ( statusCode >= 400 && statusCode < 500 ) return res . badRequest ( body ) ;
48- return res . serverError ( body ) ;
36+ return res . json ( err ) ;
4937} ;
Original file line number Diff line number Diff line change 11{
22 "name" : " sails-json-api-blueprints" ,
3- "version" : " 0.11.6 " ,
3+ "version" : " 0.12.0 " ,
44 "description" : " Blueprints to turn a Sails.js API into a JSON API" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments