Sha256: 6eaa92e7899891890df03305f269b2766b0f3b735182ce8c7df00dea8426e79c

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Cogitate
  # When the thing we are trying to decode is improperly encoded, this exception is to provide clarity
  class InvalidIdentifierEncoding < ArgumentError
    def initialize(encoded_string:)
      super("Unable to decode #{encoded_string}; Expected it to be URL-safe Base64 encoded (use Base64.urlsafe_encode64)")
    end
  end

  # When the thing we have decoded is not properly formated, this exception is to provide clarity
  class InvalidIdentifierFormat < RuntimeError
    EXPECTED_FORMAT = "strategy\tvalue\nstrategy\tvalue".freeze
    def initialize(decoded_string:)
      super("Expected #{decoded_string.inspect} to be of the format #{EXPECTED_FORMAT.inspect}")
    end
  end

  # When the thing we have decoded is not properly formated, this exception is to provide clarity
  class InvalidMembershipVisitationKeys < RuntimeError
    def initialize(identifier:, visitation_type:)
      super(
        "Unable to find membership visitation service for visitation_type: #{visitation_type.inspect}, identifier: #{identifier.inspect}"
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cogitate-0.0.2 lib/cogitate/exceptions.rb