1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//
// Copyright 2023 Zesty Tech Ltd. All rights reserved.
// Use is subject to license terms.
//
use serde_json as json;
use thiserror::Error;
use super::*;
#[derive(Debug, Error, Serialize, Deserialize)]
#[error("{message}")]
pub struct Error {
#[serde(with = "http_serde::status_code")]
pub status: http::StatusCode,
pub message: String,
}
impl From<json::Error> for Error {
fn from(error: json::Error) -> Self {
let status = http::StatusCode::INTERNAL_SERVER_ERROR;
let message = error.to_string();
Self { status, message }
}
}