|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
use crate::Database;
|
|
|
|
|
|
|
|
|
|
use actix_web::{HttpResponse, error::BlockingError};
|
|
|
|
|
use std::{sync::{PoisonError, MutexGuard}, string::FromUtf8Error};
|
|
|
|
|
use actix_web::{error::BlockingError, HttpResponse};
|
|
|
|
|
use derive_more::From;
|
|
|
|
|
use sanitize_html::errors::SanitizeError;
|
|
|
|
|
use std::{
|
|
|
|
|
string::FromUtf8Error,
|
|
|
|
|
sync::{MutexGuard, PoisonError},
|
|
|
|
|
};
|
|
|
|
|
use validator::ValidationErrors;
|
|
|
|
|
use derive_more::From;
|
|
|
|
|
|
|
|
|
|
#[derive(From, Debug)]
|
|
|
|
|
pub enum Error {
|
|
|
|
@ -43,20 +46,20 @@ impl Error {
|
|
|
|
|
| Self::PageFetchError(_) => {
|
|
|
|
|
eprintln!("{:?}", self);
|
|
|
|
|
HttpResponse::InternalServerError()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.reason(match self {
|
|
|
|
|
Self::InvalidOrigin => "invalid request origin",
|
|
|
|
|
Self::InvalidBodyEncoding(_)
|
|
|
|
|
| Self::InvalidBodyJson(_) => "invalid request body",
|
|
|
|
|
Self::InvalidBodyEncoding(_) | Self::InvalidBodyJson(_) => "invalid request body",
|
|
|
|
|
Self::InvalidUrl => "invalid request url",
|
|
|
|
|
Self::InvalidFields(_) => "invalid request field",
|
|
|
|
|
Self::InvalidContentId => "invalid request content id",
|
|
|
|
|
Self::InvalidParent => "invalid comment parent",
|
|
|
|
|
Self::EmailRequired => "comment email required",
|
|
|
|
|
Self::NameRequired => "comment name required",
|
|
|
|
|
Self::DatabaseAccessBlockingError(_)
|
|
|
|
|
| Self::DatabaseAccessPoisonError => "database access error",
|
|
|
|
|
Self::DatabaseAccessBlockingError(_) | Self::DatabaseAccessPoisonError => {
|
|
|
|
|
"database access error"
|
|
|
|
|
}
|
|
|
|
|
Self::DatabaseInternalError(_) => "database internal error",
|
|
|
|
|
Self::SanitizationError(_) => "comment sanitization error",
|
|
|
|
|
Self::PageFetchError(_) => "page fetch error",
|
|
|
|
|