Exception: Edoxen::ValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/edoxen/error.rb,
sig/edoxen.rbs

Overview

Unified validation failure shape. Produced by both:

* SchemaValidator — JSON-Schema violations and YAML syntax errors
carry source: :schema (or :syntax for Psych::SyntaxError).
* DecisionCollection.from_yaml rescues in the CLI — model parse
failures carry source: :model.

One type at the seam means callers (CLI, future renderers, tests) handle one shape instead of N.

Constant Summary collapse

SOURCE_SCHEMA =

Returns:

  • (Symbol)
:schema
SOURCE_MODEL =

Returns:

  • (Symbol)
:model
SOURCE_SYNTAX =

Returns:

  • (Symbol)
:syntax

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, line:, column:, message_text:, pointer: "", source: SOURCE_SCHEMA) ⇒ ValidationError

Returns a new instance of ValidationError.

Parameters:

  • file: (String)
  • line: (Integer)
  • column: (Integer)
  • message_text: (String)
  • pointer: (String) (defaults to: "")
  • source: (Symbol) (defaults to: SOURCE_SCHEMA)


22
23
24
25
26
27
28
29
30
# File 'lib/edoxen/error.rb', line 22

def initialize(file:, line:, column:, message_text:, pointer: "", source: SOURCE_SCHEMA)
  @file = file
  @line = line
  @column = column
  @pointer = pointer.to_s
  @message_text = message_text
  @source = source
  super(to_clickable_format)
end

Instance Attribute Details

#columnInteger (readonly)

Returns the value of attribute column.

Returns:

  • (Integer)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def column
  @column
end

#fileString (readonly)

Returns the value of attribute file.

Returns:

  • (String)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def file
  @file
end

#lineInteger (readonly)

Returns the value of attribute line.

Returns:

  • (Integer)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def line
  @line
end

#message_textString (readonly)

Returns the value of attribute message_text.

Returns:

  • (String)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def message_text
  @message_text
end

#pointerString (readonly)

Returns the value of attribute pointer.

Returns:

  • (String)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def pointer
  @pointer
end

#sourceSymbol (readonly)

Returns the value of attribute source.

Returns:

  • (Symbol)


20
21
22
# File 'lib/edoxen/error.rb', line 20

def source
  @source
end

Instance Method Details

#to_clickable_formatString

Returns:

  • (String)


32
33
34
35
# File 'lib/edoxen/error.rb', line 32

def to_clickable_format
  suffix = @pointer.empty? ? "" : " at `#{@pointer}`"
  "#{@file}:#{@line}:#{@column}: #{@message_text}#{suffix}"
end