Errors that are thrown from the JS SDK are mostly unusable, because almost all of them are plain new Error(/* ... */) invocations, rather than proper classified errors, like those provided in errors.ts. This leaves users using generic try/catch along with string literal matching in the .message field in order to try and detect what type of error is thrown. This is problematic, because it would likely not be a breaking change if the underlying Rust error string representation changed, which would break users relying on message content when discerning errors.
The same is true for scope signup / signin clause too, ex having custom logic in theses expression with throw will always result in the same error without the throwed message
Describe the bug
Errors that are thrown from the JS SDK are mostly unusable, because almost all of them are plain
new Error(/* ... */)
invocations, rather than proper classified errors, like those provided inerrors.ts
. This leaves users using generic try/catch along with string literal matching in the.message
field in order to try and detect what type of error is thrown. This is problematic, because it would likely not be a breaking change if the underlying Rust error string representation changed, which would break users relying on message content when discerning errors.All possible errors can be found here.
Steps to reproduce
Expected behaviour
Provide some way of discerning between error kinds.
SurrealDB version
1.1.0
SurrealDB.js version
0.11.0
Contact Details
No response
Is there an existing issue for this?
Code of Conduct