Skip to content

Custom error type allowing to wrap errors one in another

Notifications You must be signed in to change notification settings

LeMisterV/wrappederror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wrapped Error

This module allows you to wrap error objects inside other error objects, and to join data to an error object.

This is a simple way to improve errors while catching them, and to get the complet detail/history of an error when you intent to do something out of this error.

const Werror = require('wrappederror');

const errorTypes = {
  STRANGE_ERROR: {
    name: 'strange-error',
    message: 'a strange error occured'
  }
};

try {
  anythingThrowing();
} catch (error) {
  throw Werror.wrap(error, errorTypes.STRANGE_ERROR, {
    key: 'value'
  });
}

About

Custom error type allowing to wrap errors one in another

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published