update the error message as well

This commit is contained in:
Tamo 2022-12-20 17:31:13 +01:00
parent 52aa34d984
commit 3040172562
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69

View File

@ -23,7 +23,10 @@ pub struct ResponseError {
}
impl ResponseError {
pub fn from_msg(message: String, code: Code) -> Self {
pub fn from_msg(mut message: String, code: Code) -> Self {
if code == Code::IoError {
message.push_str(". This error generally happens when you have no space left on device or when your database doesn't have read or write right.");
}
Self {
code: code.http(),
message,
@ -47,13 +50,7 @@ where
T: ErrorCode,
{
fn from(other: T) -> Self {
Self {
code: other.http_status(),
message: other.to_string(),
error_code: other.error_name(),
error_type: other.error_type(),
error_link: other.error_url(),
}
Self::from_msg(other.to_string(), other.error_code())
}
}
@ -111,7 +108,7 @@ impl fmt::Display for ErrorType {
}
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
pub enum Code {
// error related to your setup
IoError,