Skip to content

Add ability to customize default Parse Errors #7915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
dblythy opened this issue Apr 1, 2022 · 2 comments
Open
3 tasks done

Add ability to customize default Parse Errors #7915

dblythy opened this issue Apr 1, 2022 · 2 comments
Labels
type:feature New feature or improvement of existing feature

Comments

@dblythy
Copy link
Member

dblythy commented Apr 1, 2022

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

@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza mtrezza added the type:feature New feature or improvement of existing feature label Apr 3, 2022
@mtrezza
Copy link
Member

mtrezza commented Apr 9, 2022

How practically useable is this?

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?

The original post says:

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

No branches or pull requests

2 participants