class RBS::CLI::Validate::Errors

公共类方法

new(limit:, exit_error:) 点击以切换源代码
# File rbs-3.8.0/lib/rbs/cli/validate.rb, line 7
def initialize(limit:, exit_error:)
  @limit = limit
  @exit_error = exit_error
  @errors = []
  @has_syntax_error = false
end

公共实例方法

add(error) 点击以切换源代码
# File rbs-3.8.0/lib/rbs/cli/validate.rb, line 14
def add(error)
  if error.instance_of?(WillSyntaxError)
    RBS.logger.warn(build_message(error))
    @has_syntax_error = true
  else
    @errors << error
  end
  finish if @limit == 1
end
finish() 点击以切换源代码
# File rbs-3.8.0/lib/rbs/cli/validate.rb, line 24
def finish
  if @errors.empty?
    if @exit_error && @has_syntax_error
      exit 1
    else
      # success
    end
  else
    @errors.each do |error|
      RBS.logger.error(build_message(error))
    end
    exit 1
  end
end

私有实例方法

build_message(error) 点击以切换源代码
# File rbs-3.8.0/lib/rbs/cli/validate.rb, line 41
def build_message(error)
  if error.respond_to?(:detailed_message)
    highlight = RBS.logger_output ? RBS.logger_output.tty? : true
    error.detailed_message(highlight: highlight)
  else
    "#{error.message} (#{error.class})"
  end
end