Open
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
Sometimes, it would be good to customize the internal errors caused by Parse Server.
Feature / Enhancement Description
It would be good to have a Cloud Function where we could register Parse.Cloud.onError(className, (error) => {});
where the error can be customized before returning to the client.
Example Use Case
An example of this is if you have mongodb unique schemas set up. Let's say you have the fields "foo" to be unique on the class "Test". If a duplicate "foo" value is presented, the error will be "A duplicate value for a field with unique values was provided" which is often useless to clients. It would be good to be able to do:
Parse.Cloud.onError("Test", (error) => {
if (error.code === Parse.Error.DUPLICATE_VALUE) {
error.message = 'Foo has already been used. Please try a different one';
}
});
Alternatives / Workarounds
Use enableExpressErrorHandler
3rd Party References
https://community.parseplatform.org/t/server-wide-custom-error-messages/255