Skip to main content

ErrorCode

Struct ErrorCode 

Source
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

Source

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");
Source

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);
Source

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");
Source

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.

Source

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.

Source

pub const LEASE_REVOKED: Self

lease_revoked, 403: the lease was revoked by withdrawal, suspension, application disable or removal. A job exits at once.

Source

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.

Source

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.

Source

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.

Source

pub const BUSY: Self

busy, 503: the proxy (or a signer socket) is at its concurrency limit. A job retries.

Source

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.

Source

pub const KEY_DISABLED: Self

key_disabled, 403: the signer refuses the key: it is disabled, destroyed, unknown or the node key.

Source

pub const NO_WINDOW: Self

no_window, 403: the signer has no signing window open for this key and lease.

Source

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.

Source

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.

Source

pub const APPLICATION_UNAVAILABLE: Self

application_unavailable, 409: an installation names an application that is not approved.

Source

pub const IMAGE_HAS_VOLUMES: Self

image_has_volumes, 409: the image’s configuration declares a volume, refused at approval and again at create.

Source

pub const IMAGE_ABSENT: Self

image_absent, 409: the runner reports the image ID absent from the tenant daemon.

Source

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.

Source

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.

Source

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.

Source

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);
Source

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);
Source

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)));
Source

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");
Source

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);
Source

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);

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ErrorCode

Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

§

impl Forget for ErrorCode

§

impl Freeze for ErrorCode
where &'static str: Freeze,

§

impl Move for ErrorCode

§

impl RefUnwindSafe for ErrorCode

§

impl Send for ErrorCode
where &'static str: Send,

§

impl Sync for ErrorCode

§

impl Unpin for ErrorCode
where &'static str: Unpin,

§

impl UnsafeUnpin for ErrorCode
where &'static str: UnsafeUnpin,

§

impl UnwindSafe for ErrorCode
where &'static str: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.