@@ -4,16 +4,16 @@ http = require 'http'
4
4
5
5
class @Error extends Error
6
6
7
- constructor : (@message = ' Unknown error' , @neo4j = {}) ->
7
+ constructor : (@message = ' Unknown error' , @neo4j = {}, _stackStart ) ->
8
8
@name = ' neo4j.' + @constructor .name
9
- Error .captureStackTrace @ , @constructor
9
+ Error .captureStackTrace @ , _stackStart
10
10
11
11
#
12
12
# Accepts the given HTTP client response, and if it represents an error,
13
13
# creates and returns the appropriate Error instance from it.
14
14
# If the response doesn't represent an error, returns null.
15
15
#
16
- @ _fromResponse: (resp ) ->
16
+ @ _fromResponse: (resp , _stackStart = arguments . callee ) ->
17
17
{body , headers , statusCode } = resp
18
18
19
19
return null if statusCode < 400
@@ -23,7 +23,7 @@ class @Error extends Error
23
23
# TODO: Is it possible to get back more than one error?
24
24
# If so, is it fine for us to just use the first one?
25
25
[error ] = body .errors
26
- return @ _fromObject error
26
+ return @ _fromObject error, _stackStart
27
27
28
28
# TODO: Do some status codes (or perhaps inner `exception` names)
29
29
# signify Transient errors rather than Database ones?
@@ -44,13 +44,13 @@ class @Error extends Error
44
44
if logBody and body?
45
45
message += " : #{ JSON .stringify body, null , 4 } "
46
46
47
- new ErrorClass message, body
47
+ new ErrorClass message, body, _stackStart
48
48
49
49
#
50
50
# Accepts the given (Neo4j v2) error object, and creates and returns the
51
51
# appropriate Error instance for it.
52
52
#
53
- @ _fromObject: (obj ) ->
53
+ @ _fromObject: (obj , _stackStart = arguments . callee ) ->
54
54
# NOTE: Neo4j 2.2 seems to return both `stackTrace` and `stacktrace`.
55
55
# https://github.com/neo4j/neo4j/issues/4145#issuecomment-78203290
56
56
# Normalizing to consistent `stackTrace` before we parse below!
@@ -93,7 +93,7 @@ class @Error extends Error
93
93
else
94
94
fullMessage += message
95
95
96
- new ErrorClass fullMessage, obj
96
+ new ErrorClass fullMessage, obj, _stackStart
97
97
98
98
# TODO: Helper to rethrow native/inner errors? Not sure if we need one.
99
99
0 commit comments