dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

abstract unique constraint error code #632

Open kapouer opened 9 years ago

kapouer commented 9 years ago

Hi, i am finding myself doing

instance.save(function(err) {
  if (err && err.code == 23505) return res.sendStatus(409);
  ...
});

and it's bad because it depends on the error code returned by postgres for a duplicate key constraint violation. It would be nicer to have a specific orm error in that situation.