use thiserror::Error;
#[derive(Error, Debug)]
pub enum ServerError {
#[error("could not serialize JSON")]
Disconnect(#[from] serde_json::Error),
#[error("error creating response")]
Response(#[from] http::Error),
}
#[derive(Error, Debug)]
pub enum ClientError {
#[error(transparent)]
Query(#[from] async_graphql::ParseRequestError),
#[error("Could not parse JSON body")]
Json(#[from] serde_json::Error),
#[error("Binary body must be encoded with UTF-8")]
InvalidBinaryBody(#[from] std::str::Utf8Error),
#[error("Only GET and POST methods are allowed")]
MethodNotAllowed,
}
impl ServerError {
pub fn into_lambda_error(self) -> lambda_http::Error {
lambda_http::Error::from(self.to_string())
}
}
impl ClientError {
pub fn into_lambda_error(self) -> lambda_http::Error {
lambda_http::Error::from(self.to_string())
}
}