From 215b743dedaa8bd4d88a8f761525d83a5b3dc916 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Sat, 31 Aug 2013 15:45:46 -0500 Subject: [PATCH] maybe code climate likes this way better? --- lib/neography/connection.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb index 25691d3..f3b9d72 100644 --- a/lib/neography/connection.rb +++ b/lib/neography/connection.rb @@ -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)