Open antislash21 opened 4 years ago
I think server side errors are 500s by default to limit information exposure, but you can overwrite this behaviour in SimpleSchema by using the transform hook to allow it:
SimpleSchema.defineValidationErrorTransform(error => {
const ddpError = new Meteor.Error(error.message);
ddpError.error = 'validation-error';
ddpError.details = error.details;
return ddpError;
});
I'm not 100% sure on this though, but this snippet is what we use so 🤷♂
@coagmano : I already tried to include this on server startup without success. It seems the Error is not processed by SimpleSchema. As you can see in my example, my method ends up with an exception coming directly from npm-mongo library.
If this can help, the application code is here: https://gitlab.mim-libre.fr/alphabet/laboite
schema is defined in app/imports/api/groups/groups.js the methods called are createGroup and updateGroup from app/imports/api/groups/methods.js there are unit tests in app/imports/api/groups/server/groups.tests.js (you can search for E11000 duplicate key).
can confirm the same issue as this.
I currently use unique index on a field in an application
When inserting or updating in the table with an already existing name, I don't get a [40X] error with details.
On the server, i get the following kind of error while updating
and while inserting
On client side this results in a 500 internal error with no details
I see in collection2 code that these kind of errors should result in Meteor.Error with error 409, this doesn't seem to be the case.
I upgraded to these versions before reporting this
meteor version 1.9.0 simpl-schema 1.5.6 aldeed:collection2 3.0.6 aldeed:schema-index 3.0.0
Thanks for your work and time spent here