GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ehmicky/is-error-instance: Check if a value is an `Error` instance.

BranchesTags
Open more actions menu

Latest commit

 

History

427 Commits
427 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
.all-contributorsrc
.all-contributorsrc
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
ava.config.js
ava.config.js
 
 
eslint.config.js
eslint.config.js
 
 
gulpfile.js
gulpfile.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
prettier.config.js
prettier.config.js
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Node Browsers TypeScript Codecov Minified size Mastodon Medium

Check if a value is an Error instance.

This is like value instanceof Error except it works across realms, such as iframes or Node.js vm.

Example

import isErrorInstance from 'is-error-instance'

isErrorInstance(new Error('')) // true
isErrorInstance('') // false

const CrossRealmError = vm.runInNewContext('Error')
isErrorInstance(new CrossRealmError('')) // true

isErrorInstance(new TypeError('')) // true
isErrorInstance(new AnyOtherError('')) // true

isErrorInstance(new DOMException('')) // true
isErrorInstance(new DOMError('')) // true

isErrorInstance(new Proxy(new Error(''), {})) // true
isErrorInstance(
  new Proxy(new Error(''), {
    getPrototypeOf: () => {
      throw new Error('')
    },
  }),
) // false

Install

npm install is-error-instance

This package works in both Node.js >=18.18.0 and browsers.

This is an ES module. It must be loaded using an import or import() statement, not require(). If TypeScript is used, it must be configured to output ES modules, not CommonJS.

API

isErrorInstance(value)

value any
Return value: boolean

Related projects

  • modern-errors: Handle errors in a simple, stable, consistent way
  • error-custom-class: Create one error class
  • error-class-utils: Utilities to properly create error classes
  • error-serializer: Convert errors to/from plain objects
  • merge-error-cause: Merge an error with its cause
  • normalize-exception: Normalize exceptions/errors
  • set-error-class: Properly update an error's class
  • set-error-message: Properly update an error's message
  • wrap-error-message: Properly wrap an error's message
  • set-error-props: Properly update an error's properties
  • set-error-stack: Properly update an error's stack
  • error-cause-polyfill: Polyfill error.cause
  • handle-cli-error: 💣 Error handler for CLI applications 💥
  • beautiful-error: Prettify error messages and stacks
  • log-process-errors: Show some ❤ to Node.js process errors
  • error-http-response: Create HTTP error responses
  • winston-error-format: Log errors with Winston

Support

For any question, don't hesitate to submit an issue on GitHub.

Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.

Contributing

This project was made with ❤️. The simplest way to give back is by starring and sharing it online.

If the documentation is unclear or has a typo, please click on the page's Edit button (pencil icon) and suggest a correction.

If you would like to help us fix a bug or add a new feature, please check our guidelines. Pull requests are welcome!

About

Check if a value is an `Error` instance.

Topics

browsercross-realmdomerrorerror-handleerror-handlererror-handlerserror-handlingerror-monitoringerror-reportingerrorsexceptionexception-handlinginstanceofjavascriptlibrarymonitoringnodejstestingtypescript

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

Generated from ehmicky/template-javascript
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.