Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw errors in sails v1.0.0-37 #56

Open
dc-me opened this issue Oct 2, 2017 · 6 comments
Open

throw errors in sails v1.0.0-37 #56

dc-me opened this issue Oct 2, 2017 · 6 comments

Comments

@dc-me
Copy link

dc-me commented Oct 2, 2017

sails> Page.create({name:'t'}).exec(console.log)Error (E_UNKNOWN) :: Encountered an unexpected error
at new WLError (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/error/WLError.js:26:15)
at Object.module.exports.patch (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/lib/WLValidationError.js:8:13)
at /Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/lib/create.js:66:48
at _.extend._WLModel (/Users/dany/Projects/rocket-common-h5/node_modules/waterline/lib/waterline/methods/create.js:155:20)
at parley (/Users/dany/Projects/rocket-common-h5/node_modules/parley/lib/parley.js:111:5)
at newConstructor.create (/Users/dany/Projects/rocket-common-h5/node_modules/waterline/lib/waterline/methods/create.js:130:10)
at newConstructor.create (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/lib/create.js:47:14)
at module.exports.Deferred.exec (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/query/deferred.js:477:16)
at repl:1:25
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:239:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:440:10)
at emitOne (events.js:120:20)
at REPLServer.emit (events.js:210:7)
at REPLServer.Interface._onLine (readline.js:282:10)
at REPLServer.Interface._line (readline.js:631:8)
at REPLServer.Interface._ttyWrite (readline.js:911:14)
at REPLServer.self._ttyWrite (repl.js:509:7)
at ReadStream.onkeypress (readline.js:160:10)
at emitTwo (events.js:125:13)

is it the waterline's version? because the v1 uses a new one.

@dc-me
Copy link
Author

dc-me commented Oct 3, 2017

I have found multiple incompatibility with the sails v1, there is no error.invalidAttributes, and the create method doesn't have meta. which fails to work with the v1.

@LucasMcL
Copy link

LucasMcL commented Oct 3, 2017

I am having the same issues. The custom error messages are not attaching to the error object in Sails v1.

@mp3por
Copy link

mp3por commented Nov 16, 2017

Hello,

So will we be getting v1 support or not ?

@educweb
Copy link

educweb commented Aug 2, 2018

@danywheeler is correct. It seems that in Sails v1 the format of the errors has been changed dramatically.

{
  "code": "E_INVALID_NEW_RECORD",
  "details": "New record contains the wrong type of data for property `value`.  Specified value is not a valid `value`.  1 error validating value: \n • Specified value (a string: '') doesn't match the expected type: 'number'",
  "message": "The server could not fulfill this request (`POST /api/equipment`) due to a problem with the parameters that were sent.  See the `details` for more info.  **The following additional tip will not be shown in production**:  Tip: Check your client-side code to make sure that the request data it sends matches the expectations of the corresponding attribues in your model.  Also check that your client-side code sends data for every required attribute."
}

@jvanalst
Copy link

jvanalst commented Aug 2, 2018

Additionally,

WLError no longer exists and instead, Waterline is mostly generating errors through the Flaverr.js library. So that whole piece of code will need to be rethought.

To boot, most validation errors are generated deep inside the Waterline normalization process. And Waterline also tends to give up after the first error detected (often a type error, or required attribute error). Only high level (e.g. minLength, email, etc.) come back with anything like the old array (which is now named ruleViolations).

@sayjeyhi
Copy link

based on discussions we could not use this hook with v1 of sails :-\ , please add it on docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants