isError()function

isError(v: unknown): v is Error & { readonly code?: string | undefined }
ParamType
vunknown
The value to check and narrow. required
Return
v is Error & { readonly code?: string | undefined }
true if v is an Error (narrowing it, with an optional code string).

Is an unknown value an Error instance?

  • Uses the native Error.isError() if available, otherwise falls back to instanceof Error.