Exception: Neo4j::Core::CypherSession::CypherError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/neo4j/core/cypher_session/adaptors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code = nil, original_message = nil, stack_trace = nil) ⇒ CypherError


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 14

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


12
13
14
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 12

def code
  @code
end

#original_messageObject (readonly)

Returns the value of attribute original_message


12
13
14
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 12

def original_message
  @original_message
end

#stack_traceObject (readonly)

Returns the value of attribute stack_trace


12
13
14
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 12

def stack_trace
  @stack_trace
end

Class Method Details

.error_class_from(code) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 31

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

.new_from(code, message, stack_trace = nil) ⇒ Object


27
28
29
# File 'lib/neo4j/core/cypher_session/adaptors.rb', line 27

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