Skip to content

Add ability to customize default Parse Errors #7915

Open
@dblythy

Description

@dblythy

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions