Sha256: c19faf92711aab4f42d0f4fae4a70f5e82ceec8484a12031a24339f3caacc7f8

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

module Cloudhdr
  class Error < StandardError

    def initialize(error_or_message)
      if error_or_message.is_a?(Exception)
        @error = error_or_message
      else
        @message = error_or_message
      end
    end

    def message
      @message || "#{@error.class} (wrapped in a #{self.class}) - #{@error.message}"
    end

    def backtrace
      if @error
        @error.backtrace
      else
        super
      end
    end

    def inspect
      if @error
        "#{@error.inspect} (wrapped in a #{self.class})"
      else
        super
      end
    end

    def to_s
      if @error
        "#{@error.class} (wrapped in a #{self.class}) - #{@error}"
      else
        super
      end
    end
  end

  class HTTPError < Error; end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cloudhdr-0.0.3 lib/cloudhdr/errors.rb
cloudhdr-0.0.2 lib/cloudhdr/errors.rb
cloudhdr-0.0.1 lib/cloudhdr/errors.rb