Skip to content

isError

Checks if a value is an Error instance.

Available since v2.0.0

import { isError } from '@helpers4/guard';
// or, from the all-in-one package (same code, one install):
import { isError } from 'helpers4/guard';
isError(value: unknown): value is Error
ParameterTypeDescription
valueunknownThe value to check

value is Error — True if value is an Error (or subclass like TypeError, RangeError, etc.)

isError(new Error('oops'))     // => true
isError(new TypeError('bad'))  // => true
isError({ message: 'fake' })  // => false

View source on GitHub