Skip to main content

ToolError

Struct ToolError 

Source
pub struct ToolError {
    pub code: ErrorCode,
    pub message: String,
    pub exit_code: Option<i32>,
    pub stderr: Option<String>,
    pub status: Option<u16>,
    pub hint: Option<String>,
}
Expand description

A failed tool call, as the client sees it.

Every string field has already been through redact by the time it is here: the constructors do it, so a caller cannot forget.

Fields§

§code: ErrorCode§message: String§exit_code: Option<i32>

The process exit code, when a process is what failed.

§stderr: Option<String>

What the process wrote to its standard error, trimmed and redacted.

§status: Option<u16>

The HTTP status, when the control plane is what failed.

§hint: Option<String>

What the caller can do about it. Present on every code where the fix is something the caller or operator controls.

Implementations§

Source§

impl ToolError

Source

pub fn new(code: ErrorCode, message: impl Into<String>) -> Self

The general constructor. Prefer the named ones below; this exists for the paths that compute their own code.

Source

pub fn with_exit_code(self, exit_code: i32) -> Self

Source

pub fn with_stderr(self, stderr: impl AsRef<str>) -> Self

Source

pub fn with_status(self, status: u16) -> Self

Source

pub fn with_hint(self, hint: impl Into<String>) -> Self

Source

pub fn cli_failed(argv0: &str, exit_code: Option<i32>, stderr: &str) -> Self

The tailscale binary exited non-zero.

The code is optional because a process killed by a signal has none, and saying so is more use to the caller than inventing a number.

Source

pub fn api_error(status: u16, body: &str) -> Self

The control plane returned a status we do not model more precisely.

Source

pub fn timeout(what: &str, seconds: u64, printed: &str) -> Self

A command that did not finish. printed is whatever it had said before it was stopped, which for a command that waits on someone else is usually the whole explanation.

Source

pub fn not_permitted(tool: &str, needs: &str) -> Self

A tool was reached that this server is not permitted to run. In the normal case such tools are hidden rather than refused, so this fires when a client calls a name it did not get from the listing.

Source

pub fn needs_operator(stderr: &str) -> Self

Source

pub fn unsupported_version(tool: &str, needs: &str, found: &str) -> Self

Source

pub fn backend_unavailable(what: &str, why: &str) -> Self

Source

pub fn invalid_args(message: impl Into<String>) -> Self

Source

pub fn unsupported_platform(tool: &str, platform: &str) -> Self

Source

pub fn not_found(what: &str) -> Self

Source

pub fn conflict(message: impl Into<String>) -> Self

A version this caller holds is no longer the current one. Carries 409 the way not_found carries 404: a client that branches on the status should not have to know which of the two this server chose to name.

Source

pub fn rate_limited(retry_after: Option<u64>) -> Self

Source

pub fn result_too_large(bytes: usize, cap: usize) -> Self

Source

pub fn confirmation_required(tool: &str, consequence: &str) -> Self

Source

pub fn to_value(&self) -> Value

The wire form: what a client receives as the structured content of a failed call. Falls back to a bare code if serialisation ever fails, so that a caller always gets something it can branch on.

Trait Implementations§

Source§

impl Clone for ToolError

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 Debug for ToolError

Source§

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

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

impl Display for ToolError

Source§

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

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

impl Eq for ToolError

Source§

impl Error for ToolError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ApiError> for ToolError

A control-plane failure, in the vocabulary a client can branch on.

tailscale_rest deliberately names its variants for what happened rather than for what a caller should be told, so that the crate can be used without this server’s error model. This is the other half of that arrangement, and the one place the translation happens: every tailnet tool reaches the control plane through ?, so nothing has to remember to call it.

Source§

fn from(error: ApiError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ToolError

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 Serialize for ToolError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ToolError

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more