use http;
use lambda_runtime::error::LambdaErrorExt;
use std::{error::Error, fmt};
#[derive(Debug)]
pub struct NowError {
msg: String,
}
impl NowError {
pub fn new(message: &str) -> NowError {
NowError {
msg: message.to_owned(),
}
}
}
impl fmt::Display for NowError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.msg)
}
}
impl Error for NowError {}
impl From<std::num::ParseIntError> for NowError {
fn from(i: std::num::ParseIntError) -> Self {
NowError::new(&format!("{}", i))
}
}
impl From<http::Error> for NowError {
fn from(i: http::Error) -> Self {
NowError::new(&format!("{}", i))
}
}
impl LambdaErrorExt for NowError {
fn error_type(&self) -> &str {
"NowError"
}
}