Comparing version 5.0.0 to 5.0.1
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/Kikobeats/whoops", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"main": "src/index.js", | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -14,2 +14,3 @@ # whoops | ||
- Attach extra information, being flexible with whatever user case. | ||
- Less than 50 lines (~500 bytes) | ||
@@ -16,0 +17,0 @@ This library is a compromise to provide a clean API for use `Error` native class. |
@@ -8,8 +8,9 @@ 'use strict' | ||
super(raw) | ||
const { message, ...props } = typeof raw === 'string' ? { message: raw } : raw | ||
const mergedProps = Object.assign({}, defaults, props) | ||
Object.keys(mergedProps).forEach(key => (this[key] = mergedProps[key])) | ||
if (message) this.description = typeof message === 'function' ? message(this) : message | ||
const { message, ...props } = Object.assign( | ||
{}, | ||
defaults, | ||
typeof raw === 'string' ? { message: raw } : raw | ||
) | ||
Object.keys(props).forEach(key => (this[key] = props[key])) | ||
if (message) this.description = typeof message === 'function' ? message(props) : message | ||
this.message = this.code ? `${this.code}, ${this.description}` : this.description | ||
@@ -16,0 +17,0 @@ this.name = name || ErrorClass.name |
9889
38
141