module Fulfillment Error = Class.new(StandardError) # HTTP errors HttpError = Class.new(Error) ServerError = Class.new(HttpError) # Service errors class ServiceError < Error attr_reader :error def initialize(response_body = {}) @error = response_body.fetch("error", {}) if response_body end def message error&.dig("message") end alias_method :to_s, :message def status error&.dig("status") end def type error&.dig("type") end end InvalidRequest = Class.new(ServiceError) InvalidEvent = Class.new(ServiceError) AccessDenied = Class.new(ServiceError) ResourceNotFound = Class.new(ServiceError) MethodNotAllowed = Class.new(ServiceError) end