pub struct ChatbotError {
error_type: <ChatbotError as BackendError>::ErrorType,
message: String,
source: Option<Error>,
span_trace: Box<SpanTrace>,
backtrace: Box<Backtrace>,
location: Option<&'static Location<'static>>,
azure_source: Option<Box<ResponseError>>,
}Expand description
Error type used in ChatbotError, which is used for errors related to chatbot functionality.
All the information in the error is meant to be seen by the user. The type of error is determined by the ChatbotErrorType enum, which is stored inside this struct.
§Examples
§Usage without source error
if erroneous_condition {
return Err(ChatbotError::new(
ChatbotErrorType::Other,
"File not found".to_string(),
None,
));
}§Usage with a source error
Used when calling a function that returns an error that cannot be automatically converted to an ChatbotError. (See impl From<X> implementations on this struct.)
some_function_returning_an_error().map_err(|original_error| {
ChatbotError::new(
ChatbotErrorType::Other,
"Library x failed to do y".to_string(),
Some(original_error.into()),
)
})?;Fields§
§error_type: <ChatbotError as BackendError>::ErrorType§message: String§source: Option<Error>Original error that caused this error.
span_trace: Box<SpanTrace>A trace of tokio tracing spans, generated automatically when the error is generated.
backtrace: Box<Backtrace>Stack trace, generated automatically when the error is created.
location: Option<&'static Location<'static>>Source location where the error was raised.
azure_source: Option<Box<ResponseError>>Implementations§
Source§impl ChatbotError
impl ChatbotError
fn render_clean_error(&self, out: &mut dyn Write, color: ColorChoice) -> Result
Sourcepub fn clean_string(&self, color: ColorChoice) -> String
pub fn clean_string(&self, color: ColorChoice) -> String
Render this error in the clean developer format.
Source§impl ChatbotError
impl ChatbotError
pub fn azure_source(&self) -> Option<AzureResponseError>
pub fn add_azure_source(&mut self, err: AzureResponseError)
Trait Implementations§
Source§impl BackendError for ChatbotError
impl BackendError for ChatbotError
type ErrorType = ChatbotErrorType
fn backtrace(&self) -> Option<&Backtrace>
fn error_type(&self) -> &Self::ErrorType
fn message(&self) -> &str
fn span_trace(&self) -> &SpanTrace
Source§fn location(&self) -> Option<&'static Location<'static>>
fn location(&self) -> Option<&'static Location<'static>>
Source§fn new_with_traces_and_location<M: Into<String>, S: Into<Option<Error>>>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
location: Option<&'static Location<'static>>,
) -> Self
fn new_with_traces_and_location<M: Into<String>, S: Into<Option<Error>>>( error_type: Self::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, location: Option<&'static Location<'static>>, ) -> Self
Source§fn new<M, S>(error_type: Self::ErrorType, message: M, source_error: S) -> Self
fn new<M, S>(error_type: Self::ErrorType, message: M, source_error: S) -> Self
Source§fn new_with_traces<M, S>(
error_type: Self::ErrorType,
message: M,
source_error: S,
backtrace: Backtrace,
span_trace: SpanTrace,
) -> Self
fn new_with_traces<M, S>( error_type: Self::ErrorType, message: M, source_error: S, backtrace: Backtrace, span_trace: SpanTrace, ) -> Self
new but with an explicit backtrace and span trace, e.g. to
preserve a source error’s traces.fn to_different_error<T>( self, new_error_type: <T as BackendError>::ErrorType, new_message: String, ) -> T
Source§impl Debug for ChatbotError
impl Debug for ChatbotError
Source§impl Display for ChatbotError
impl Display for ChatbotError
Source§impl Error for ChatbotError
impl Error for ChatbotError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Source§fn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
replaced by Error::source, which can support downcasting
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for ChatbotError
impl From<Error> for ChatbotError
Source§impl From<Error> for ChatbotError
impl From<Error> for ChatbotError
Source§impl From<Error> for ChatbotError
impl From<Error> for ChatbotError
Source§fn from(err: Error) -> ChatbotError
fn from(err: Error) -> ChatbotError
Source§impl From<Error> for ChatbotError
impl From<Error> for ChatbotError
Source§fn from(err: Error) -> ChatbotError
fn from(err: Error) -> ChatbotError
Source§impl From<Error> for ChatbotError
impl From<Error> for ChatbotError
Source§fn from(err: Error) -> ChatbotError
fn from(err: Error) -> ChatbotError
Source§impl From<ModelError> for ChatbotError
impl From<ModelError> for ChatbotError
Source§fn from(err: ModelError) -> ChatbotError
fn from(err: ModelError) -> ChatbotError
Source§impl From<ParseError> for ChatbotError
impl From<ParseError> for ChatbotError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl From<SearchFilterError> for ChatbotError
impl From<SearchFilterError> for ChatbotError
Source§fn from(err: SearchFilterError) -> ChatbotError
fn from(err: SearchFilterError) -> ChatbotError
Auto Trait Implementations§
impl Freeze for ChatbotError
impl !RefUnwindSafe for ChatbotError
impl Send for ChatbotError
impl Sync for ChatbotError
impl Unpin for ChatbotError
impl UnsafeUnpin for ChatbotError
impl !UnwindSafe for ChatbotError
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> ErrorTrace for Twhere
T: BackendError,
impl<T> ErrorTrace for Twhere
T: BackendError,
Source§fn span_trace(&self) -> &SpanTrace
fn span_trace(&self) -> &SpanTrace
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<E> InstrumentError for Ewhere
TracedError<E>: From<E>,
impl<E> InstrumentError for Ewhere
TracedError<E>: From<E>,
§type Instrumented = TracedError<E>
type Instrumented = TracedError<E>
§fn in_current_span(self) -> <E as InstrumentError>::Instrumented
fn in_current_span(self) -> <E as InstrumentError>::Instrumented
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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].