pub enum CapabilityError {
InvalidInput(String),
NotFound(String),
Refused(String),
Internal(String),
Forbidden(String),
}Expand description
Why a call did not produce an output. Transport adapters map these to their own vocabularies; nothing here names a status code or a JSON-RPC code.
Variants§
InvalidInput(String)
The input did not deserialize into the handler’s type, or a filter named something the repository does not have.
NotFound(String)
The thing asked for does not exist: an object, a capability.
Refused(String)
The input is well-formed and the call is declined, with the reason (a blank query).
Internal(String)
The handler itself failed; never the caller’s fault.
Forbidden(String)
The caller may not run this from where it is: a request from another host for a capability that changes something and does not authenticate its input (ADR 0126).
Implementations§
Source§impl CapabilityError
impl CapabilityError
Sourcepub fn code(&self) -> &'static str
pub fn code(&self) -> &'static str
The category as one word, the same on every transport: the error.code of an HTTP
answer and the _meta.majordomus.error.code of an MCP tool result that is an error.
A caller branches on this and reads the message; it never has to parse the message
to learn which of the five happened.
use majordomus_cli::capability::CapabilityError;
assert_eq!(CapabilityError::InvalidInput("x".into()).code(), "invalid_input");
assert_eq!(CapabilityError::NotFound("x".into()).code(), "not_found");
assert_eq!(CapabilityError::Refused("x".into()).code(), "refused");
assert_eq!(CapabilityError::Internal("x".into()).code(), "internal");
assert_eq!(CapabilityError::Forbidden("x".into()).code(), "forbidden");Sourcepub fn remote(id: &str) -> Self
pub fn remote(id: &str) -> Self
The refusal a caller on another host meets when it asks for a capability that changes something and does not authenticate its input. One sentence on every transport, so the HTTP route and the MCP tool refuse alike.
use majordomus_cli::capability::CapabilityError;
let e = CapabilityError::remote("plan.transition");
assert_eq!(e.code(), "forbidden");
assert!(e.to_string().contains("plan.transition"));Trait Implementations§
Source§impl Clone for CapabilityError
impl Clone for CapabilityError
Source§fn clone(&self) -> CapabilityError
fn clone(&self) -> CapabilityError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CapabilityError
impl Debug for CapabilityError
Source§impl Display for CapabilityError
impl Display for CapabilityError
impl Eq for CapabilityError
Source§impl Error for CapabilityError
impl Error for CapabilityError
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 PartialEq for CapabilityError
impl PartialEq for CapabilityError
Source§fn eq(&self, other: &CapabilityError) -> bool
fn eq(&self, other: &CapabilityError) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CapabilityError
Auto Trait Implementations§
impl Freeze for CapabilityError
impl RefUnwindSafe for CapabilityError
impl Send for CapabilityError
impl Sync for CapabilityError
impl Unpin for CapabilityError
impl UnsafeUnpin for CapabilityError
impl UnwindSafe for CapabilityError
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.