Sha256: de2830338452a493e6bd3dcfe692d62f8c275f6933ab18c4d7d2795a0c6665be

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

module Neo4j
  module Core
    class CypherError < StandardError
      attr_reader :code, :original_message, :stack_trace

      def initialize(code = nil, original_message = nil, stack_trace = nil)
        @code = code
        @original_message = original_message
        @stack_trace = stack_trace

        msg = <<-ERROR
  Cypher error:
  #{ANSI::CYAN}#{code}#{ANSI::CLEAR}: #{original_message}
  #{stack_trace}
        ERROR
        super(msg)
      end

      def self.new_from(code, message, stack_trace = nil)
        error_class_from(code).new(code, message, stack_trace)
      end

      def self.error_class_from(code)
        case code
        when /(ConstraintValidationFailed|ConstraintViolation)/
          SchemaErrors::ConstraintValidationFailedError
        when /IndexAlreadyExists/
          SchemaErrors::IndexAlreadyExistsError
        when /ConstraintAlreadyExists/ # ?????
          SchemaErrors::ConstraintAlreadyExistsError
        else
          CypherError
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
activegraph-10.0.0.pre.alpha.11 lib/neo4j/core/cypher_error.rb
activegraph-10.0.0.pre.alpha.10 lib/neo4j/core/cypher_error.rb
activegraph-10.0.0.pre.alpha.9 lib/neo4j/core/cypher_error.rb
activegraph-10.0.0.pre.alpha.8 lib/neo4j/core/cypher_error.rb
activegraph-10.0.0.pre.alpha.7 lib/neo4j/core/cypher_error.rb
activegraph-10.0.0.pre.alpha.6 lib/neo4j/core/cypher_error.rb
neo4j-10.0.0.pre.alpha.5 lib/neo4j/core/cypher_error.rb
neo4j-10.0.0.pre.alpha.4 lib/neo4j/core/cypher_error.rb
neo4j-10.0.0.pre.alpha.3 lib/neo4j/core/cypher_error.rb
neo4j-10.0.0.pre.alpha.2 lib/neo4j/core/cypher_error.rb
neo4j-10.0.0.pre.alpha.1 lib/neo4j/core/cypher_error.rb