1.3.3 • Published 7 years ago

shoutr v1.3.3

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

shoutr

build status coverage code quality dependencies status devDependencies status npm licence npm version Greenkeeper badge semantic-release Commitizen friendly code style - airbnb/base

Install

npm:

npm install shoutr

yarn:

yarn add shoutr

Usage

import { registerErrors, throwError } from 'shoutr';

registerErrors({
  wrongParamType: (type) => `You passed param with wrong type: ${type} - expected object`;
  someError: 'some string error, without any params';
});

const param = 'some string';

throwError('wrongParamType', TypeError, typeof param);
// should throw an TypeError with message equal 'You passed param with wrong type: string - expected object'

throwError('wrongParamType', typeof param);
// should throw an Error with message equal 'You passed param with wrong type: string - expected object'

throwError('someError');
// should throw an Error with message equal 'some string error, without any params'

throwError('someError', ReferenceError);
// should throw an ReferenceError with message equal 'some string error, without any params'

throwError('error which is not in registered errors');
// should throw an Error with message equal 'error which is not in registered errors'

Contributors

NameWebsite
Bart Smyklahttps://smykla.com

License

MIT © Bart Smykla

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago