You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was investigating this library and found that orWhen accepts an Error. I took a look at the internals of this library and found that there's a cast to Error in
From what I can see there's technically no guarantee that what's being throw is an Error. Someone could, for instance, if they really wanted do, say throw 'some error message' - Not ideal but sometimes we have no control over what's being thrown as the thrown error might live in, say, a third party library.
As such, I propose that we replace the use of Error + the cast to unknown
The text was updated successfully, but these errors were encountered:
ghost91-
added a commit
to ghost91-/cockatiel
that referenced
this issue
Jul 20, 2024
Instead, errors are now consistently typed as `unknown`.
BREAKING CHANGE: The types of errors have been changed from `Error` to unknown because they are not statically known (in JavaScript, _anything_ can be thrown).
If you know that in a particular situation, errors can only be instances of
`Error`, you can do the type assertion yourself (`error as Error`). Otherwise,
you should check whether an error is actually an `Error`, for example with
`error instanceof Error`.
Closesconnor4312#87
Was investigating this library and found that
orWhen
accepts anError
. I took a look at the internals of this library and found that there's a cast toError
incockatiel/src/common/Executor.ts
Line 67 in 03614ab
From what I can see there's technically no guarantee that what's being throw is an
Error
. Someone could, for instance, if they really wanted do, saythrow 'some error message'
- Not ideal but sometimes we have no control over what's being thrown as the thrown error might live in, say, a third party library.As such, I propose that we replace the use of
Error
+ the cast tounknown
The text was updated successfully, but these errors were encountered: