Sha256: fa2bf78491cf81cceca817b2069c16bef67fbfa3cfe773550dbce491dd3d2ea2

Contents?: true

Size: 841 Bytes

Versions: 25

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

#
# Copyright 2013 whiteleaf. All rights reserved.
#

module Narou
  module Mixin
    module OutputError
      def output_error(io, exception)
        outputter = proc do
          io.puts "#{$@.shift}: #{exception.message} (#{exception.class})"
          $@.each do |b|
            io.puts "  from #{b}"
          end
        end
        # MEMO: report_on_exception は Ruby 2.4.0 から実装
        if Thread.respond_to?(:report_on_exception) && Thread.report_on_exception
          # report_on_exception が有効な場合は標準出力へのエラー表示はそっちに任せる。
          # silence を使うことで、標準出力には表示されないがログには記録される
          io.silence(&outputter)
        else
          outputter.call
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
narou-3.9.1 lib/mixin/output_error.rb
narou-3.9.0 lib/mixin/output_error.rb
narou-3.8.2 lib/mixin/output_error.rb
narou-3.8.1 lib/mixin/output_error.rb
narou-3.8.0 lib/mixin/output_error.rb
narou-3.7.2 lib/mixin/output_error.rb
narou-3.7.1 lib/mixin/output_error.rb
narou-3.7.0 lib/mixin/output_error.rb
narou-3.6.0 lib/mixin/output_error.rb
narou-3.5.1 lib/mixin/output_error.rb
narou-3.5.0.1 lib/mixin/output_error.rb
narou-3.5.0 lib/mixin/output_error.rb
narou-3.4.8 lib/mixin/output_error.rb
narou-3.4.7.1 lib/mixin/output_error.rb
narou-3.4.7 lib/mixin/output_error.rb
narou-3.4.6.1 lib/mixin/output_error.rb
narou-3.4.6 lib/mixin/output_error.rb
narou-3.4.5 lib/mixin/output_error.rb
narou-3.4.3 lib/mixin/output_error.rb
narou-3.4.2 lib/mixin/output_error.rb