pub struct AppError(/* private fields */);Expand description
Implementations§
Trait Implementations§
Source§impl<E> From<E> for AppError
自动转换其他错误类型为 AppError
impl<E> From<E> for AppError
自动转换其他错误类型为 AppError
这使得可以在返回 Result<_, AppError> 的函数中直接使用 ? 操作符
§示例
fn my_function() -> Result<(), AppError> {
// 自动转换 std::io::Error 为 AppError
let _content = std::fs::read_to_string("file.txt")?;
Ok(())
}Source§impl IntoResponse for AppError
实现 Axum 响应转换
impl IntoResponse for AppError
实现 Axum 响应转换
将错误转换为 HTTP 500 响应,并记录错误日志
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl Freeze for AppError
impl RefUnwindSafe for AppError
impl Send for AppError
impl Sync for AppError
impl Unpin for AppError
impl UnsafeUnpin for AppError
impl UnwindSafe for AppError
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
Mutably borrows from an owned value. Read more