press-f
Version:
A funny replace to Error class
108 lines (74 loc) • 1.83 kB
Markdown
//github.com/gastonpereyra/press-f/workflows/Build%20Status/badge.svg)
[](https://coveralls.io/r/gastonpereyra/press-f?branch=master)

When an Error happens, press "f" to pay respect. A funny replace to Error class.
```
npm i press-f
```
Replace of `new Error('some message')`
```js
const F = require('press-f');
if(shouldNotHappen())
throw new F('This should not happen because i don\'t like it');
/*
output:
throw new F(This should not happen because i don\'t like it');
^
Press F: This should not happen because i don't like it
at ...
*/
```
Replace of `new Error()`
```js
const F = require('press-f');
if(shouldNotHappen())
throw new F();
/*
output:
throw new F();
^
Press F: Pay Respect
at ...
*/
```
Replace of `new Error(message)` but change Error name for a custom one, if `name` is *string*
```js
const F = require('press-f');
if(shouldNotHappen())
throw new F('I don\'t care', 'This is not an Error');
/*
output:
throw new F();
^
This is not an Error: I don't care
at ...
*/
```
If `F` create from another Error can get this one using the getter `previousError`
```js
const F = require('press-f');
try {
shouldNotHappen();
} catch (error) {
throw new F(error, 'Custom');
}
/*
output:
throw new F(error, 'Custom');
^
Custom: Error: 'Old Error'
at ...
name: 'Custom',
previousError: Error: 'Old Error'
at ...
*/
```
![Build Status](https: