Skip to content

Commit

Permalink
maybe code climate likes this way better?
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Aug 31, 2013
1 parent 7fe6b95 commit 215b743
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,29 @@ def handle_4xx_500_response(code, body)
end

def raise_errors(code, exception, message, stacktrace)
error = nil
case code
when 401
raise UnauthorizedError.new(message, code, stacktrace)
error = UnauthorizedError
when 409
raise OperationFailureException.new(message, code, stacktrace)
error = OperationFailureException
end

case exception
when /SyntaxException/ ; raise SyntaxException.new(message, code, stacktrace)
when /this is not a query/ ; raise SyntaxException.new(message, code, stacktrace)
when /PropertyValueException/ ; raise PropertyValueException.new(message, code, stacktrace)
when /BadInputException/ ; raise BadInputException.new(message, code, stacktrace)
when /NodeNotFoundException/ ; raise NodeNotFoundException.new(message, code, stacktrace)
when /NoSuchPropertyException/ ; raise NoSuchPropertyException.new(message, code, stacktrace)
when /RelationshipNotFoundException/ ; raise RelationshipNotFoundException.new(message, code, stacktrace)
when /NotFoundException/ ; raise NotFoundException.new(message, code, stacktrace)
when /UniquePathNotUniqueException/ ; raise UniquePathNotUniqueException.new(message, code, stacktrace)
error ||= case exception
when /SyntaxException/ ; SyntaxException
when /this is not a query/ ; SyntaxException
when /PropertyValueException/ ; PropertyValueException
when /BadInputException/ ; BadInputException
when /NodeNotFoundException/ ; NodeNotFoundException
when /NoSuchPropertyException/ ; NoSuchPropertyException
when /RelationshipNotFoundException/ ; RelationshipNotFoundException
when /NotFoundException/ ; NotFoundException
when /UniquePathNotUniqueException/ ; UniquePathNotUniqueException
else
NeographyError
end

raise NeographyError.new(message, code, stacktrace)
raise error.new(message, code, stacktrace)
end

def parse_string_options(options)
Expand Down

0 comments on commit 215b743

Please sign in to comment.