Sha256: 252d72ba37802ae1b2f86011fe6a80f6a78653d88a7f76edd0983f8ebb6d970e

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module RRD
  class Error < StandardError
    attr_reader :code, :description

    def initialize(code, description)
      super(description)
      @code = code
      @description = description
    end

    class << self
      def for_code(code)
        case code
        when '100'; UsernameNotFoundError
        when '110'; PasswordNotFoundError
        when '120'; TrackingNumberNotFoundError
        when '130'; AuthenticationError
        when '200'; ShippingSiteError
        when '300'; DatabaseError
        when '400'; BadTrackingNumberError
        else      ; Error
        end
      end
    end
  end

  class ValidationError < Error; end
  class UsernameNotFoundError < ValidationError; end
  class PasswordNotFoundError < ValidationError; end
  class TrackingNumberNotFoundError < ValidationError; end
  class AuthenticationError < Error; end
  class ShippingSiteError < Error; end
  class DatabaseError < Error; end
  class BadTrackingNumberError < Error; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rrd-track-1.0.1 lib/rrd-track/errors.rb