parse-community / docs

Parse Platform docs
https://docs.parseplatform.org
Other
313 stars 517 forks source link

Define built-in error code range #943

Closed mtrezza closed 10 months ago

mtrezza commented 4 years ago

Is your feature request related to a problem? Please describe. It can be useful to throw a custom Parse.Error in cloud code and handle that specific error on the client side by error code.

For example an error, when a user account is banned.

throw new Parse.Error(9001, "account banned");

If a new built-in Parse Error is introduced in the future, it can conflict with the custom error code. There is currently no way to prevent such a future conflict as the range for built-in error codes is not defined in the docs.

Describe the solution you'd like Define the built-in error code range in the docs ...-999, so custom error codes won't conflict. Currently, built-in Parse Error codes have up to 3 digits.

Alternatives Reserve an error code range for custom errors, e.g. 9001-9999.

Additional context Not sure in which range adapters (push adapter, etc) are currently throwing.

SebC99 commented 4 years ago

I agree, having the 141 error for each cloudFunction error is hard to deal with. We have to test for 141, then go inside the error, to find another code, which is not very convenient...

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mtrezza commented 4 years ago

OK, then I guess we only have to add a range to the docs.

I noticed that 3rd party modules may want to use custom error codes too. So should we define a suggested range for these as well?

SebC99 commented 4 years ago

Well, the only change to do in the docs in my opinion is to add something about the usage of new Parse.Error(code, message) which let developer uses any code they want.

mtrezza commented 1 year ago

@parse-community/server any thoughts on this?

The current suggestion is to define the following error code ranges:

mtrezza commented 10 months ago

After some more thought, I don't believe that the "3rd party modules" range is feasible because it would have to be community managed, for which I don't see a concept. So I would say that for now we'll just specify that developers have a reserved error range >=9000 <=9999 which they can use for custom errors. Neither Parse Server now any Parse Server adapter or module should use that range, and an 3rd party module should not use the range to prevent conflicts.

mtrezza commented 10 months ago

Closing via https://github.com/parse-community/docs/pull/941