Skip to content

Commit ed15bf4

Browse files
committed
v2 / Errors: mask low-level stack a bit more.
1 parent 5e46e5c commit ed15bf4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib-new/errors.coffee

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ http = require 'http'
44

55
class @Error extends Error
66

7-
constructor: (@message='Unknown error', @neo4j={}) ->
7+
constructor: (@message='Unknown error', @neo4j={}, _stackStart) ->
88
@name = 'neo4j.' + @constructor.name
9-
Error.captureStackTrace @, @constructor
9+
Error.captureStackTrace @, _stackStart
1010

1111
#
1212
# Accepts the given HTTP client response, and if it represents an error,
1313
# creates and returns the appropriate Error instance from it.
1414
# If the response doesn't represent an error, returns null.
1515
#
16-
@_fromResponse: (resp) ->
16+
@_fromResponse: (resp, _stackStart=arguments.callee) ->
1717
{body, headers, statusCode} = resp
1818

1919
return null if statusCode < 400
@@ -23,7 +23,7 @@ class @Error extends Error
2323
# TODO: Is it possible to get back more than one error?
2424
# If so, is it fine for us to just use the first one?
2525
[error] = body.errors
26-
return @_fromObject error
26+
return @_fromObject error, _stackStart
2727

2828
# TODO: Do some status codes (or perhaps inner `exception` names)
2929
# signify Transient errors rather than Database ones?
@@ -44,13 +44,13 @@ class @Error extends Error
4444
if logBody and body?
4545
message += ": #{JSON.stringify body, null, 4}"
4646

47-
new ErrorClass message, body
47+
new ErrorClass message, body, _stackStart
4848

4949
#
5050
# Accepts the given (Neo4j v2) error object, and creates and returns the
5151
# appropriate Error instance for it.
5252
#
53-
@_fromObject: (obj) ->
53+
@_fromObject: (obj, _stackStart=arguments.callee) ->
5454
# NOTE: Neo4j 2.2 seems to return both `stackTrace` and `stacktrace`.
5555
# https://github.com/neo4j/neo4j/issues/4145#issuecomment-78203290
5656
# Normalizing to consistent `stackTrace` before we parse below!
@@ -93,7 +93,7 @@ class @Error extends Error
9393
else
9494
fullMessage += message
9595

96-
new ErrorClass fullMessage, obj
96+
new ErrorClass fullMessage, obj, _stackStart
9797

9898
# TODO: Helper to rethrow native/inner errors? Not sure if we need one.
9999

0 commit comments

Comments
 (0)