ARCP errors are structured values with a canonical code, message, retry hint, optional details, and optional cause.
return nil, arcp.ErrPermissionDenied.WithMessage("model not in lease")
return nil, arcp.Newf(arcp.CodeInternalError, "marshal: %v", err)| Code | Sentinel | Default retryable |
|---|---|---|
PERMISSION_DENIED |
ErrPermissionDenied |
false |
LEASE_SUBSET_VIOLATION |
ErrLeaseSubsetViolation |
false |
JOB_NOT_FOUND |
ErrJobNotFound |
false |
DUPLICATE_KEY |
ErrDuplicateKey |
false |
AGENT_NOT_AVAILABLE |
ErrAgentNotAvailable |
false |
AGENT_VERSION_NOT_AVAILABLE |
ErrAgentVersionNotAvailable |
false |
CANCELLED |
ErrCancelled |
false |
TIMEOUT |
ErrTimeout |
false |
RESUME_WINDOW_EXPIRED |
ErrResumeWindowExpired |
false |
HEARTBEAT_LOST |
ErrHeartbeatLost |
true |
LEASE_EXPIRED |
ErrLeaseExpired |
false |
BUDGET_EXHAUSTED |
ErrBudgetExhausted |
false |
INVALID_REQUEST |
ErrInvalidRequest |
false |
UNAUTHENTICATED |
ErrUnauthenticated |
false |
INTERNAL_ERROR |
ErrInternalError |
true |
arcp.Code(err)walks the error chain and returns the first embeddedErrorCode. Non-arcp errors returnCodeInternalError.arcp.IsRetryable(err)returns the embeddedRetryableflag for arcp errors. Non-arcp errors returntrueby default — a conservative choice so generic transport-level errors don't become fatal.arcp.Newf(code, format, args...)constructs an*Errorwith a formatted message and the default retryable flag for the code (trueforCodeInternalErrorandCodeHeartbeatLost,falseotherwise).(*Error).WithCause(err),(*Error).WithMessage(msg),(*Error).WithDetails(map)return copies of the sentinel with the field overridden.errors.Is(err, arcp.ErrBudgetExhausted)matches by code through wrapping (the*Error.Ismethod compares byCode).
The runtime uses arcp.Code(err) and arcp.IsRetryable(err) to
populate job.error and session.error. Returning a wrapped
sentinel from an AgentFunc is therefore the simplest way to surface
the right code:
return nil, arcp.ErrPermissionDenied.WithMessage("model not in lease").WithCause(err)Provisioners should return credentials.BudgetExhausted when an
upstream credential cap is depleted; the variable is aliased to
arcp.ErrBudgetExhausted, so callers see BUDGET_EXHAUSTED either
way.