Skip to content

Commit 4bbb5e0

Browse files
committed
Use Error's own properties to fill object
1 parent ac1a1d1 commit 4bbb5e0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

error.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ Blueprint = {
88
if (this.handleError) {
99
this.handleError = false
1010

11-
if (typeof data === 'object' && data.constructor.name === 'Error')
12-
return callback(null, { message: data.message, stack: data.stack })
11+
if (typeof data === 'object' && data.constructor.name === 'Error') {
12+
var error = {}
13+
14+
Object.getOwnPropertyNames(data).forEach(function(key) {
15+
error[key] = data[key]
16+
})
17+
18+
return callback(null, error)
19+
}
1320

1421
callback(null, data)
1522
}

0 commit comments

Comments
 (0)