pub enum FinamError {
Status {
code: Code,
message: String,
},
Config(String),
Auth(String),
}Expand description
Error of the Finam protocol layer: a gRPC status, a configuration problem or a refused login.
The Display text never contains the API secret or a token.
§Examples
use brokapi_finam_protocol::FinamError;
use tonic::Code;
let err = FinamError::from(tonic::Status::new(Code::ResourceExhausted, "too many requests"));
assert_eq!(err.code(), Some(Code::ResourceExhausted));
assert!(err.is_rate_limited());
// The server said "no" before doing anything: a command was not applied.
assert!(err.is_definite_rejection());
// A dropped connection may have happened after the request was written.
let lost = FinamError::from(tonic::Status::new(Code::Unavailable, "connection reset"));
assert!(!lost.is_definite_rejection());Variants§
Status
gRPC status returned by the server (or synthesized by the transport).
Fields
code: CodegRPC status code. A failed connection also arrives as a status, the code depends on the failure.
Config(String)
Bad endpoint, empty secret, malformed token payload.
Auth(String)
Authentication failed (bad secret, token refused).
Implementations§
Source§impl FinamError
impl FinamError
Sourcepub fn code(&self) -> Option<Code>
pub fn code(&self) -> Option<Code>
gRPC status code, or None for FinamError::Config and FinamError::Auth.
Sourcepub fn is_unauthenticated(&self) -> bool
pub fn is_unauthenticated(&self) -> bool
true for status UNAUTHENTICATED: the JWT is missing, wrong or expired.
A read may renew the token and repeat. A command must not be repeated automatically.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
true for status RESOURCE_EXHAUSTED: the request quota is spent and the request was not run.
Sourcepub fn is_definite_rejection(&self) -> bool
pub fn is_definite_rejection(&self) -> bool
The server certainly did not process the request (so a command was NOT applied).
Conservative: Unavailable is NOT here, because a connection can drop after the request
was written. For commands every other failure is an unknown outcome.
Trait Implementations§
Source§impl Clone for FinamError
impl Clone for FinamError
Source§fn clone(&self) -> FinamError
fn clone(&self) -> FinamError
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 FinamError
impl Debug for FinamError
Source§impl Display for FinamError
impl Display for FinamError
Source§impl Error for FinamError
impl Error for FinamError
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()
Auto Trait Implementations§
impl Freeze for FinamError
impl RefUnwindSafe for FinamError
impl Send for FinamError
impl Sync for FinamError
impl Unpin for FinamError
impl UnsafeUnpin for FinamError
impl UnwindSafe for FinamError
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].