module Regexp::Scanner

def self.validation_error(type, what, reason)

errors.
Centralizes and unifies the handling of validation related
def self.validation_error(type, what, reason)
  case type
  when :group
    error = InvalidGroupError.new(what, reason)
  when :backref
    error = InvalidBackrefError.new(what, reason)
  when :sequence
    error = InvalidSequenceError.new(what, reason)
  else
    error = ValidationError.new('expression')
  end
  # TODO: configuration option to treat scanner level validation
  # errors as warnings or ignore them
  if false # @@config.validation_warn
    $stderr.puts error.to_s # unless @@config.validation_ignore
  else
    raise error # unless @@config.validation_ignore
  end
end