Sha256: 74885e14d28d77288b5a59095493ad26434e53f0071debed27d7f1a7b7301138

Contents?: true

Size: 755 Bytes

Versions: 4

Compression:

Stored size: 755 Bytes

Contents

module Zencoder
  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

4 entries across 4 versions & 1 rubygems

Version Path
zencoder-2.3.3 lib/zencoder/errors.rb
zencoder-2.3.2 lib/zencoder/errors.rb
zencoder-2.3.1 lib/zencoder/errors.rb
zencoder-2.3.0 lib/zencoder/errors.rb