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
impl ToolError
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
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.
pub fn with_exit_code(self, exit_code: i32) -> Self
pub fn with_stderr(self, stderr: impl AsRef<str>) -> Self
pub fn with_status(self, status: u16) -> Self
pub fn with_hint(self, hint: impl Into<String>) -> Self
Sourcepub fn cli_failed(argv0: &str, exit_code: Option<i32>, stderr: &str) -> Self
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.
Sourcepub fn api_error(status: u16, body: &str) -> Self
pub fn api_error(status: u16, body: &str) -> Self
The control plane returned a status we do not model more precisely.
Sourcepub fn timeout(what: &str, seconds: u64, printed: &str) -> Self
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.
Sourcepub fn not_permitted(tool: &str, needs: &str) -> Self
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.
pub fn needs_operator(stderr: &str) -> Self
pub fn unsupported_version(tool: &str, needs: &str, found: &str) -> Self
pub fn invalid_args(message: impl Into<String>) -> Self
pub fn unsupported_platform(tool: &str, platform: &str) -> Self
pub fn not_found(what: &str) -> Self
Sourcepub fn conflict(message: impl Into<String>) -> Self
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.
pub fn rate_limited(retry_after: Option<u64>) -> Self
pub fn result_too_large(bytes: usize, cap: usize) -> Self
pub fn confirmation_required(tool: &str, consequence: &str) -> Self
Trait Implementations§
impl Eq for ToolError
Source§impl Error for ToolError
impl Error for ToolError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ApiError> for ToolError
A control-plane failure, in the vocabulary a client can branch on.
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.
impl StructuralPartialEq for ToolError
Auto Trait Implementations§
impl Freeze for ToolError
impl RefUnwindSafe for ToolError
impl Send for ToolError
impl Sync for ToolError
impl Unpin for ToolError
impl UnsafeUnpin for ToolError
impl UnwindSafe for ToolError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.