Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor custom Error class to be "Neo4jError". fixes #211 #216

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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