lib/grumlin/request_error_factory.rb in grumlin-0.22.1 vs lib/grumlin/request_error_factory.rb in grumlin-0.22.2

- old
+ new

@@ -16,15 +16,23 @@ # Neptune presumably returns message as a JSON string of format # {"detailedMessage":"", # "requestId":"UUID", # "code":"ConcurrentModificationException"} - # Currencly we simply search for substings to identify the exact error + # Currently we simply search for substrings to identify the exact error # TODO: parse json and use `code` instead + VERTEX_ALREADY_EXISTS = "Vertex with id already exists:" EDGE_ALREADY_EXISTS = "Edge with id already exists:" + CONCURRENT_VERTEX_INSERT_FAILED = "Failed to complete Insert operation for a Vertex due to conflicting concurrent" + + CONCURRENT_VERTEX_PROPERTY_INSERT_FAILED = + "Failed to complete Insert operation for a VertexProperty due to conflicting concurrent" + CONCURRENT_EDGE_PROPERTY_INSERT_FAILED = + "Failed to complete Insert operation for a EdgeProperty due to conflicting concurrent" + CONCURRENT_EDGE_INSERT_FAILED = "Failed to complete Insert operation for an Edge due to conflicting concurrent" CONCURRENCT_MODIFICATION_FAILED = "Failed to complete operation due to conflicting concurrent" class << self def build(request, response) @@ -47,12 +55,18 @@ def already_exists_error(status) return VertexAlreadyExistsError if status[:message]&.include?(VERTEX_ALREADY_EXISTS) return EdgeAlreadyExistsError if status[:message]&.include?(EDGE_ALREADY_EXISTS) end - def concurrent_modification_error(status) + def concurrent_modification_error(status) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity return ConcurrentVertexInsertFailedError if status[:message]&.include?(CONCURRENT_VERTEX_INSERT_FAILED) + if status[:message]&.include?(CONCURRENT_VERTEX_PROPERTY_INSERT_FAILED) + return ConcurrentVertexPropertyInsertFailedError + end return ConcurrentEdgeInsertFailedError if status[:message]&.include?(CONCURRENT_EDGE_INSERT_FAILED) + if status[:message]&.include?(CONCURRENT_EDGE_PROPERTY_INSERT_FAILED) + return ConcurrentEdgePropertyInsertFailedError + end return ConcurrentModificationError if status[:message]&.include?(CONCURRENCT_MODIFICATION_FAILED) end end end end