1.3.3 • Published 8 years ago
shoutr v1.3.3
shoutr
Install
npm:
npm install shoutryarn:
yarn add shoutrUsage
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
| Name | Website | 
|---|---|
| Bart Smykla | https://smykla.com |