blob: ccec59fedc402fc1aaae8580dcb6386c9904201a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  | 
use hyper::{Body, Error, Response, StatusCode};
pub struct WebhookError {
    pub code: StatusCode,
    pub message: String,
}
impl WebhookError {
    pub fn new(code: StatusCode, message: &str) -> WebhookError {
        WebhookError {
            code,
            message: message.to_string(),
        }
    }
}
impl Into<Response<Body>> for WebhookError {
    fn into(self) -> Response<Body> {
        Response::builder()
            .status(self.code)
            .body(self.message.into())
            .unwrap()
    }
}
  |