Uh oh!
There was an error while loading. Please reload this page.
Replace numeric error codes with strings - #309
Conversation
ddd66fe to
12ad4a8Comparealecgibson
commented
Sep 13, 2019
I've done this PR in a relatively "dumb" way, just blindly swapping out numeric codes for strings as I saw fit. While we're here, I think it would be good to think about:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alecgibson
commented
Oct 9, 2019
As a rough rule of thumb, let's group object formatting issues under single codes, but for any user input (eg |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alecgibson
commented
Oct 9, 2019
Let's go ahead with |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
We should also add something to the README that talks about errors a consumer is likely to run into, and what do about them:
ERR_OP_SUBMIT_REJECTED(normal - for telling client to roll back)ERR_OP_ALREADY_SUBMITTED(normal - the middleware abuses it to stop all further execution by looking like an error, but then the agent just swallows it because it's non-fatal)ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUNDERR_MAX_SUBMIT_RETRIES_EXCEEDEDERR_DOC_ALREADY_CREATEDERR_DOC_ALREADY_DELETEDERR_DOC_TYPE_NOT_RECOGNISED
(Advanced use:)ERR_OP_NOT_ALLOWED_IN_PROJECTIONERR_DEFAULT_TYPE_MISMATCH
Fixes#287Fixes#198 This is a breaking change that moves us from using numeric error codes to string-based codes [similar to Node][1]. The motivation for this is: - more descriptive error codes - stop implying that errors can be broadly classified together (in the same way that HTTP errors might) This change also exposes these codes on `ShareDBError.code`, so that they are easily discoverable, and can be referenced by consumers for programmatic error handling. [1]: https://nodejs.org/api/errors.html#nodejs-error-codes
This change aims to reword our new error codes according to review comments. The main changes are: - Prefix all code keys with `ERR_` - Rename to follow the <subject>_<state> format - Tweak some error code specificity - Provide a bit more context with some error messages
- Add documentation for common errors - Americanize spelling - Add a special error for invalid Milestone DB arguments
alecgibson
commented
Nov 13, 2019
While we're here, let's also replace all of our anonymous error objects with instances of an actual In short we should:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This change drops our dependence on `make-error`, and instead implements our own simple `ShareDBError` class, which extends `Error`. We also wrap all anonymous error objects in this `ShareDBError`, so that its type can be checked by consumers.
Fixes#287
Fixes#198
This is a breaking change that moves us from using numeric error codes
to string-based codes similar to Node.
The motivation for this is:
same way that HTTP errors might)
This change also exposes these codes on
ShareDBError.code, so thatthey are easily discoverable, and can be referenced by consumers for
programmatic error handling.