Sha256: 4f065857ca6e5bf9d934a892600b52180e83d8ce37dcd455ac6ee43f54172de5

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

module Centro
  module Error

    class Base < StandardError; end

    class ClientError < Base
      attr_reader :response

      def initialize(ex, response = nil)
        @wrapped_exception = nil
        @response = response

        if ex.respond_to?(:backtrace)
          super(ex.message)
          @wrapped_exception = ex
        else
          super(ex.to_s)
        end
      end

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

      def inspect
        %(#<#{self.class}>)
      end
    end
    
    class ConnectionFailed < ClientError; end
    class ResourceNotFound < ClientError; end
    class ParsingError     < ClientError; end
    class TimeoutError     < ClientError; end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
centro-client-0.0.4 lib/centro/errors.rb
centro-client-0.0.3 lib/centro/errors.rb