I am using Sequelize as an ORM. Here is my user model:
User = exports.User = globals.sequelize.define "User", username: globals.Sequelize.STRING email: type: globals.Sequelize.STRING validate: isEmail: true hash: globals.Sequelize.STRING salt: globals.Sequelize.STRING(512) fname: globals.Sequelize.STRING lname: globals.Sequelize.STRING country: globals.Sequelize.STRING
I save user:
globals.models.User.findOrCreate username: "johny" password: "pass" email: "johny93[###]example.com" .success (user, created)-> console.log user.values res.send 200 .error -> console.log err # how to catch this? res.send 502
If the email is valid (email: " johny93@example.com "), everything works fine. But if the email fails verification (as in the example above), I get an insert error. How to catch the type of error? .error method cannot get any error parameters.
f1nn
source share