simplify-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

simplify-error

catch unknown errors and transform it to an object as { simpleError: { error: string, message: string } }

Installation

npm install simplify-error

or using yarn

yarn add simplify-error

Example

import { simplifyError, simplifyCaughtError } from 'simplify-error';

// returns { simpleError: { error: 'Error', message: 'Some error description' } }
simplifyError('Error', 'Some error description');

// returns { simpleError: { error: 'Error', message: 'some custom error' } }
simplifyCaughtError(new Error('some custom error'));

// returns { simpleError: { error: 'Error', message: 'testing error' } }
simplifyCaughtError('testing error');

// returns { simpleError: { error: 'access_denied', message: 'Insufficient permission to invoke this function' } }
simplifyCaughtError({ error: 'access_denied', message: 'Insufficient permission to invoke this function' });

// returns { simpleError: { error: 'debugg_error', message: 'debugging error description' } }
simplifyCaughtError({ simpleError: { error: 'debugg_error', message: 'debugging error description' } });

Package Sidebar

Install

npm i simplify-error

Weekly Downloads

5

Version

1.0.1

License

MIT

Unpacked Size

4.3 kB

Total Files

5

Last publish

Collaborators

  • deflexable