Attach the original Postgres error to unique errors#180
Conversation
Currently it gets clobbered, which makes it difficult to determine which uniqueness constraint failed. This way, you can always check err.originalError to get the original node-postgres error message, with information about the constraint, PG error code and table that failed.
|
Tried to add a test here, balderdashy/waterline-adapter-tests#89, though not sure whether you can write db-specific tests there. I have tests for this in my own code |
|
Looks like this is failing on a different test, I'm not sure why. https://travis-ci.org/balderdashy/sails-postgresql/jobs/75692004#L849 (coincidentally, you can see an example of https://github.com/balderdashy/waterline/issues/1118 in the error message) |
|
just realized if people are using blueprints this may not be the best idea, since it might expose database implementation details to the end user ... ? i don't know exactly how blueprints work. |
|
The changes look good but awkwardly travis build with node 0.11 is breaking, https://travis-ci.org/balderdashy/sails-postgresql/jobs/75692004#L849: Not really sure what's going on 😕 |
|
Might be a race issue since I just re-ran the tests and they suddenly pass. I'm not sure what's going on; I believe we don't get a full stack trace because an E_VALIDATION error object does not inherit from Error. We had a bunch of issues with create([array of records]) returning results out of order; I'm not sure if that's an issue here. https://github.com/balderdashy/sails-postgresql/issues/128 |
|
Reading through the code in Sorry I don't have a huge amount of time to dig into it :( |
Attach the original Postgres error to unique errors
Currently it gets clobbered, which makes it difficult to determine which
uniqueness constraint failed. This way, you can always check err.originalError
to get the original node-postgres error message, with information about the
constraint, PG error code and table that failed.