Skip to content

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 Error
export isError

Return true if the given value is an Error object.

Instances from other realms are also supported.

@seehttps://radashi.js.org/reference/typed/isError

@example

isError(new Error()) // => true
isError('hello') // => false

@version12.2.0

isError
(new
var Error: ErrorConstructor
new (message?: string) => Error
Error
()) // => true
import _
_
.
function isError(value: unknown): value is Error
export isError

Return true if the given value is an Error object.

Instances from other realms are also supported.

@seehttps://radashi.js.org/reference/typed/isError

@example

isError(new Error()) // => true
isError('hello') // => false

@version12.2.0

isError
(new
var TypeError: TypeErrorConstructor
new (message?: string) => TypeError (+1 overload)
TypeError
()) // => true
import _
_
.
function isError(value: unknown): value is Error
export isError

Return true if the given value is an Error object.

Instances from other realms are also supported.

@seehttps://radashi.js.org/reference/typed/isError

@example

isError(new Error()) // => true
isError('hello') // => false

@version12.2.0

isError
('An error occurred') // => false
import _
_
.
function isError(value: unknown): value is Error
export isError

Return true if the given value is an Error object.

Instances from other realms are also supported.

@seehttps://radashi.js.org/reference/typed/isError

@example

isError(new Error()) // => true
isError('hello') // => false

@version12.2.0

isError
({
message: string
message
: 'Error' }) // => false