isError
Determine if a value is an Error
126 bytes
Usage
This function returns true if the input is an instance of the Error class or any of its subclasses.
import * as import _
_ from 'radashi'
import _
_.function isError(value: unknown): value is Errorexport isError
Return true if the given value is an Error object.
Instances from other realms are also supported.
isError(new var Error: ErrorConstructornew (message?: string) => Error
Error()) // => trueimport _
_.function isError(value: unknown): value is Errorexport isError
Return true if the given value is an Error object.
Instances from other realms are also supported.
isError(new var TypeError: TypeErrorConstructornew (message?: string) => TypeError (+1 overload)
TypeError()) // => trueimport _
_.function isError(value: unknown): value is Errorexport isError
Return true if the given value is an Error object.
Instances from other realms are also supported.
isError('An error occurred') // => falseimport _
_.function isError(value: unknown): value is Errorexport isError
Return true if the given value is an Error object.
Instances from other realms are also supported.
isError({ message: string
message: 'Error' }) // => false