Skip to content

Commit

Permalink
refactor custom Error class to be "Neo4jError" to resolve conflicts w…
Browse files Browse the repository at this point in the history
…ith default Error class. fixes thingdom#211
  • Loading branch information
builtbywill authored and TyGuy committed Mar 6, 2017
1 parent b730d83 commit 9448612
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions lib-new/GraphDatabase.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$ = require 'underscore'
assert = require 'assert'
Constraint = require './Constraint'
{Error} = require './errors'
{Neo4jError} = require './errors'
Index = require './Index'
lib = require '../package.json'
Node = require './Node'
Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = class GraphDatabase
# TODO: Do we want to return our own Response object?
return cb null, resp

if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

cb null, _transform resp.body
Expand Down Expand Up @@ -258,7 +258,7 @@ module.exports = class GraphDatabase
# NOTE: This includes our own errors for non-2xx responses.
return cb err

if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

_tx?._updateFromResponse resp
Expand Down Expand Up @@ -329,7 +329,7 @@ module.exports = class GraphDatabase
# TODO: Is it possible to get back more than one error?
# If so, is it fine for us to just use the first one?
[error] = errors
err = Error._fromObject error
err = Neo4jError._fromObject error

cb err, results

Expand Down Expand Up @@ -428,7 +428,7 @@ module.exports = class GraphDatabase
return cb null, null

# Translate all other error responses as legitimate errors:
if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

cb err, if resp.body then Index._fromRaw resp.body
Expand Down Expand Up @@ -457,7 +457,7 @@ module.exports = class GraphDatabase
return cb null, false

# Translate all other error responses as legitimate errors:
if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

cb err, true # Index existed and was dropped
Expand Down Expand Up @@ -555,7 +555,7 @@ module.exports = class GraphDatabase
return cb null, null

# Translate all other error responses as legitimate errors:
if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

cb err, if resp.body then Constraint._fromRaw resp.body
Expand Down Expand Up @@ -587,7 +587,7 @@ module.exports = class GraphDatabase
return cb null, false

# Translate all other error responses as legitimate errors:
if err = Error._fromResponse resp
if err = Neo4jError._fromResponse resp
return cb err

cb err, true # Constraint existed and was dropped
Expand Down
8 changes: 4 additions & 4 deletions lib-new/errors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $ = require 'underscore'
assert = require 'assert'
http = require 'http'

class @Error extends Error
class @Neo4jError extends Error

constructor: (@message='Unknown error', @neo4j={}) ->
@name = 'neo4j.' + @constructor.name
Expand Down Expand Up @@ -97,8 +97,8 @@ class @Error extends Error

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

class @ClientError extends @Error
class @ClientError extends @Neo4jError

class @DatabaseError extends @Error
class @DatabaseError extends @Neo4jError

class @TransientError extends @Error
class @TransientError extends @Neo4jError

0 comments on commit 9448612

Please sign in to comment.