| Crates.io | awred |
| lib.rs | awred |
| version | 0.2.0 |
| created_at | 2021-09-25 09:44:57.518952+00 |
| updated_at | 2021-09-26 20:16:48.274532+00 |
| description | A convenient derive macro for actix_web::ResponseError trait |
| homepage | |
| repository | https://github.com/ondra05/awred |
| max_upload_size | |
| id | 456143 |
| size | 10,809 |
A convenient derive macro for actix_web::ResponseError trait.
use awred::ResponseError;
use serde::Serialize;
use thiserror::Error;
#[derive(Debug, Error, ResponseError, Serialize)]
pub enum AnError {
#[error("Requested resource was not found")]
#[status_code(NOT_FOUND)]
ResourceNotFound,
#[error("Forbidden: {reason}")]
#[status_code(FORBIDDEN)]
Forbidden { reason: String },
// Internal Server Error
#[error(transparent)]
#[serde(skip)]
IoError(#[from] std::io::Error),
}
#[derive(Debug, Error, ResponseError, Serialize)]
#[error("Invalid username or password")]
#[status_code(BAD_REQUEST)]
pub struct InvalidCredentials;
actix_web::http::StatusCode) are specified with #[status_code(...)] attribute#[status_code(...)] attribute return Internal Server Error with empty bodyerror.to_string()){
"error": "error",
"message": "error.to_string()",
}