You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';}});
I think an error trigger where the only info is the class name and the error itself doesn't give much substance. If a class has N database operations, how would one know which save or find attempt caused the error? Or is that irrelevant, but if so, what is the practical use case for this?
In my app the error ParseError: 101 Object not found is almost certainly caused by someone not having permissions to view that object due to ACL.
That seems to be a rather vague and even unreliable ("almost certainly") hack they are trying to achieve by broadly overriding errors. There is no way of telling whether the object was actually not found or whether there was just insufficient permission.
I'm also not sure whether the proposed syntax Parse.Cloud.onError(className, (error) => {}); is versatile enough. There are server errors that are not class based, so maybe the syntax should be more universal?
New Feature / Enhancement Checklist
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:
Alternatives / Workarounds
Use
enableExpressErrorHandler
3rd Party References
https://community.parseplatform.org/t/server-wide-custom-error-messages/255
The text was updated successfully, but these errors were encountered: