-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add isErrorLike()
method
#68
Conversation
You need to update the readme too. |
👍
Sure, but we still need to keep the loose variant around for |
For now I added the
|
index.d.ts
Outdated
stack: string; | ||
message: string; | ||
code?: string; | ||
} & JsonObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& JsonObject
is not correct here because the JS code is not actually ensuring that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add cause
as optional? Same with ErrorObject
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& JsonObject is not correct here because the JS code is not actually ensuring that.
I suppose the solution is to use a generic Record then
Should we also add cause as optional? Same with ErrorObject.
Done
index.d.ts
Outdated
Predicate to determine whether a value looks like an error, even if it's not an instance of `Error`. It must have at least the `name`, `message`, and `stack` properties. | ||
|
||
@example | ||
```js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the examples use ``` too. I dropped js
though.
If you want to drop ``` from all of them it can be done in a separate commit I suppose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to drop ``` from all of them it can be done in a separate commit I suppose
👍
}); | ||
//=> false | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the back and forth. I would make the changes myself, but I don't have access since you did the PR from an org account. |
Ahh that's annoying, sorry about that |
Closes #47
Since
deserializeError
also acceptsError
instances, I decided to do the same for this detector.Names:
true
or real arraysError
instancesErrorObject
type, but it reads like "isError
object", as in "isError
instance.Unrelated suggestions:
ErrorObject
type toErrorLike
name
,message
andstack
properties of this type mandatory, because they always exist innew Error()
and its serialized counterpart