Sha256: 60e575652982c0e7ce5b321e4d24eccbe3ae6656e592c4b0edd6e378a9933655

Contents?: true

Size: 1.01 KB

Versions: 42

Compression:

Stored size: 1.01 KB

Contents

module ActiveGraph
  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

42 entries across 42 versions & 1 rubygems

Version Path
activegraph-10.1.1 lib/active_graph/core/cypher_error.rb
activegraph-11.0.1-java lib/active_graph/core/cypher_error.rb
activegraph-11.0.0-java lib/active_graph/core/cypher_error.rb
activegraph-10.1.0 lib/active_graph/core/cypher_error.rb
activegraph-11.0.0.beta.4-java lib/active_graph/core/cypher_error.rb
activegraph-10.0.2 lib/active_graph/core/cypher_error.rb
activegraph-11.0.0.beta.3-java lib/active_graph/core/cypher_error.rb
activegraph-11.0.0.beta.2-java lib/active_graph/core/cypher_error.rb
activegraph-11.0.0.beta.1-java lib/active_graph/core/cypher_error.rb
activegraph-10.0.1 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.11 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.10 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.9 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.8 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.7 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.6 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.5 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.4 lib/active_graph/core/cypher_error.rb
activegraph-10.0.0.pre.beta.3 lib/active_graph/core/cypher_error.rb