whoops 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  - An easy way to create qualified errors.
12
12
  - Using the standard `Error` interface in browser and NodeJS.
13
13
  - Attach extra information, being flexible with whatever user case.
14
+ - Less than 50 lines (~500 bytes)
14
15
 
15
16
  This library is a compromise to provide a clean API for use `Error` native class.
16
17
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "whoops",
3
3
  "description": "It makes simple throw qualified errors.",
4
4
  "homepage": "https://github.com/Kikobeats/whoops",
5
- "version": "5.0.0",
5
+ "version": "5.0.1",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "josefrancisco.verdu@gmail.com",
package/src/index.js CHANGED
@@ -5,12 +5,13 @@ function createErrorClass (ErrorClass) {
5
5
  class CustomError extends ErrorClass {
6
6
  constructor (raw = {}) {
7
7
  super(raw)
8
-
9
- const { message, ...props } = typeof raw === 'string' ? { message: raw } : raw
10
- const mergedProps = Object.assign({}, defaults, props)
11
- Object.keys(mergedProps).forEach(key => (this[key] = mergedProps[key]))
12
-
13
- if (message) this.description = typeof message === 'function' ? message(this) : message
8
+ const { message, ...props } = Object.assign(
9
+ {},
10
+ defaults,
11
+ typeof raw === 'string' ? { message: raw } : raw
12
+ )
13
+ Object.keys(props).forEach(key => (this[key] = props[key]))
14
+ if (message) this.description = typeof message === 'function' ? message(props) : message
14
15
  this.message = this.code ? `${this.code}, ${this.description}` : this.description
15
16
  this.name = name || ErrorClass.name
16
17
  }