Exception: Regexp::Scanner::ValidationError

Inherits:
ScannerError show all
Defined in:
lib/regexp_parser/scanner/errors/validation_error.rb

Overview

Base for all scanner validation errors

Class Method Summary collapse

Class Method Details

.for(type, problem, reason = nil) ⇒ Object

Centralizes and unifies the handling of validation related errors.



5
6
7
# File 'lib/regexp_parser/scanner/errors/validation_error.rb', line 5

def self.for(type, problem, reason = nil)
  types.fetch(type).new(problem, reason)
end

.typesObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/regexp_parser/scanner/errors/validation_error.rb', line 9

def self.types
  @types ||= {
    backref:      InvalidBackrefError,
    group:        InvalidGroupError,
    group_option: InvalidGroupOption,
    posix_class:  UnknownPosixClassError,
    property:     UnknownUnicodePropertyError,
    sequence:     InvalidSequenceError,
  }
end