Module: Arcp::Errors

Defined in:
lib/arcp/errors.rb

Defined Under Namespace

Classes: AgentNotAvailable, AgentVersionNotAvailable, Backpressure, BudgetExhausted, Cancelled, DuplicateKey, HeartbeatLost, Internal, InvalidRequest, JobNotFound, LeaseExpired, LeaseSubsetViolation, PermissionDenied, ProtocolViolation, RateLimited, ResumeWindowExpired, Timeout, Unauthenticated, UnnegotiatedFeature

Constant Summary collapse

ALL =
[
  Cancelled, InvalidRequest, Unauthenticated, PermissionDenied,
  JobNotFound, AgentNotAvailable, DuplicateKey, RateLimited,
  Internal, HeartbeatLost, Backpressure, ProtocolViolation, Timeout,
  ResumeWindowExpired, LeaseSubsetViolation,
  AgentVersionNotAvailable, LeaseExpired, BudgetExhausted
].freeze
WIRE_CODES =
ALL.map { |c| c::CODE }.freeze
BY_CODE =
ALL.to_h { |klass| [klass::CODE, klass] }.freeze
RETRYABLE_BY_DEFAULT =
ALL.select { |k| k.new.retryable? }.map { |k| k::CODE }.freeze
NON_RETRYABLE_BY_DEFAULT =
(WIRE_CODES - RETRYABLE_BY_DEFAULT).freeze

Class Method Summary collapse

Class Method Details

.for(code, message: nil, details: {}) ⇒ Object



126
127
128
129
# File 'lib/arcp/errors.rb', line 126

def self.for(code, message: nil, details: {})
  klass = BY_CODE[code] || Arcp::Errors::Internal
  klass.new(message, details: details)
end