Sha256: 4ade06d84eeb97823bbfb9e4f5cc84bbcf47578e4745fee31bdd767a1dd8457b

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

module Redbreast
  class ErrorHandler
    extend Helper::Terminal

    class << self
      def rescuable
        yield
      rescue => e
        handle(e)
      end

      def handle(e)
        prompt.error(
          case e
          when Errno::ENOENT
            "We could not find a file that we need:\n\n#{e.message}"
          else
            "An error happened. This might help:\n\n#{e.message}"
          end
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redbreast-0.1.2 lib/redbreast/error_handler.rb
redbreast-0.1.1 lib/redbreast/error_handler.rb
redbreast-0.1.0 lib/redbreast/error_handler.rb