pub struct ErrorCode { /* private fields */ }Expand description
An error code and the HTTP status it is sent with.
Every Stratum error response is {"error":{"code","message"}}. The codes
defined before Step 3a are written by the crate that sends them. This
type gives the codes Steps 3a and 3b add one definition, shared by the
controller, the gate, the proxy, the signer and the runner that send
them and the client and the job library that read them. Signer-internal
codes (stale_revision, no_recipients) and outcomes that are never an
HTTP answer (limits_not_applied, keys_inconsistent) are not here.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::SUSPENDED.as_str(), "suspended");
assert_eq!(ErrorCode::SUSPENDED.status(), 403);
assert_eq!(ErrorCode::from_code("archive_required"), Some(ErrorCode::ARCHIVE_REQUIRED));
assert_eq!(ErrorCode::from_code("conflict"), None);Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub const SUSPENDED: Self
pub const SUSPENDED: Self
suspended, 403: the requester, or the owner of the pod in the path,
is suspended. Also the answer to redeem and confirm by a
suspended key, decided before any stored response is looked up.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::SUSPENDED.to_string(), "suspended");Sourcepub const ARCHIVE_REQUIRED: Self
pub const ARCHIVE_REQUIRED: Self
archive_required, 409: remove requires an archive, and none was
taken for the member’s current generation and suspension number.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::ARCHIVE_REQUIRED.status(), 409);Sourcepub const POD_DATA_PRESENT: Self
pub const POD_DATA_PRESENT: Self
pod_data_present, 409: an invitation or redemption for a removed
or cancelled key whose old pod data has not been purged.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::POD_DATA_PRESENT.as_str(), "pod_data_present");Sourcepub const APP_FORBIDDEN: Self
pub const APP_FORBIDDEN: Self
app_forbidden, 403: an application key used on a route, listener or
pod it may not reach, or a member key sent to the gate’s proxy
listener.
Sourcepub const RATE_LIMITED: Self
pub const RATE_LIMITED: Self
rate_limited, 429: a principal, all application keys together, or
the whole node exceeded its signed-pod-request rate limit.
Sourcepub const LEASE_REVOKED: Self
pub const LEASE_REVOKED: Self
lease_revoked, 403: the lease was revoked by withdrawal, suspension, application disable or removal. A job exits at once.
Sourcepub const OUTSIDE_GRANT: Self
pub const OUTSIDE_GRANT: Self
outside_grant, 403: the request’s method or path is outside the installation’s grant, or the path is an ACL.
Sourcepub const LEASE_STARTING: Self
pub const LEASE_STARTING: Self
lease_starting, 503: the lease is claimed but not yet started: the runner has not verified the container’s limits or the signing window is not open. A job retries.
Sourcepub const LEASE_EXPIRED: Self
pub const LEASE_EXPIRED: Self
lease_expired, 503: the proxy holds no live lease view: the controller has not answered its poll within the 300 s view lease. A job retries until its cut-off.
Sourcepub const BUSY: Self
pub const BUSY: Self
busy, 503: the proxy (or a signer socket) is at its concurrency limit. A job retries.
Sourcepub const POD_AUTH_REFUSED: Self
pub const POD_AUTH_REFUSED: Self
pod_auth_refused, 503: the pod server answered 401, which the proxy relays as retryable: its replay cache is full. A job retries.
Sourcepub const KEY_DISABLED: Self
pub const KEY_DISABLED: Self
key_disabled, 403: the signer refuses the key: it is disabled, destroyed, unknown or the node key.
Sourcepub const NO_WINDOW: Self
pub const NO_WINDOW: Self
no_window, 403: the signer has no signing window open for this key and lease.
Sourcepub const OUTSIDE_POD: Self
pub const OUTSIDE_POD: Self
outside_pod, 403: the signer refuses a URL that is not the key’s origin followed by a non-ACL path in its owner’s pod.
Sourcepub const PAYLOAD_RULE: Self
pub const PAYLOAD_RULE: Self
payload_rule, 400: the signer refuses a payload_sha256 that is malformed, present without a body or absent with one.
Sourcepub const APPLICATION_UNAVAILABLE: Self
pub const APPLICATION_UNAVAILABLE: Self
application_unavailable, 409: an installation names an application that is not approved.
Sourcepub const IMAGE_HAS_VOLUMES: Self
pub const IMAGE_HAS_VOLUMES: Self
image_has_volumes, 409: the image’s configuration declares a volume, refused at approval and again at create.
Sourcepub const IMAGE_ABSENT: Self
pub const IMAGE_ABSENT: Self
image_absent, 409: the runner reports the image ID absent from the tenant daemon.
Sourcepub const WORKSPACE_UNAVAILABLE: Self
pub const WORKSPACE_UNAVAILABLE: Self
workspace_unavailable, 409: an installation asks for a workspace and no slot is available; always the answer to a workspace mode other than none in Step 3b-2.
Sourcepub const CONTAINER_IDENTITY_CONFLICT: Self
pub const CONTAINER_IDENTITY_CONFLICT: Self
container_identity_conflict, 409: the runner found a container with the lease’s name whose labels or effective profile differ from the request; it neither starts, stops nor removes it.
Sourcepub const CREATE_EXPIRED: Self
pub const CREATE_EXPIRED: Self
create_expired, 409: the runner received a create after the controller’s monotonic not_after and did not begin it.
Sourcepub const RUNNER_UNAVAILABLE: Self
pub const RUNNER_UNAVAILABLE: Self
runner_unavailable, 503: the controller could not complete a step
that needs the runner (an application’s approval queries the image
on the tenant daemon): no runner is configured, the runner did not
answer, or it refused. Nothing was stored; the request can be sent
again once the runner answers.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::RUNNER_UNAVAILABLE.as_str(), "runner_unavailable");
assert_eq!(ErrorCode::RUNNER_UNAVAILABLE.status(), 503);Sourcepub const SIGNER_UNAVAILABLE: Self
pub const SIGNER_UNAVAILABLE: Self
signer_unavailable, 503: an installation’s create or consent was
committed but the signer did not finish its step (making the
application key, or confirming it enabled). The commit stays;
sending the same request again, with the same operation ID, finishes
it and answers once the signer has.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::SIGNER_UNAVAILABLE.as_str(), "signer_unavailable");
assert_eq!(ErrorCode::SIGNER_UNAVAILABLE.status(), 503);Sourcepub const ALL: [Self; 23]
pub const ALL: [Self; 23]
Every code this type defines.
§Examples
use stratum_node_core::ErrorCode;
assert!(ErrorCode::ALL.iter().all(|c| ErrorCode::from_code(c.as_str()) == Some(*c)));Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Returns the code as it appears in error.code.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::POD_DATA_PRESENT.as_str(), "pod_data_present");Sourcepub const fn status(self) -> u16
pub const fn status(self) -> u16
Returns the HTTP status the code is sent with.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::ARCHIVE_REQUIRED.status(), 409);Sourcepub fn from_code(code: &str) -> Option<Self>
pub fn from_code(code: &str) -> Option<Self>
Returns the code named code, if this type defines it. The match is
exact and case-sensitive.
§Examples
use stratum_node_core::ErrorCode;
assert_eq!(ErrorCode::from_code("suspended"), Some(ErrorCode::SUSPENDED));
assert_eq!(ErrorCode::from_code("Suspended"), None);