diff options
| author | n1c00o <34602094+n1c00o@users.noreply.github.com> | 2021-10-16 22:26:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-16 22:26:09 +0200 |
| commit | e58e816ceb8caa3c77dd98a952761b7e7f05b6cb (patch) | |
| tree | ca5c9409986ff538e7a674473c1d642627d1055c /webhook/src/handler/error.rs | |
| parent | 03908129599260587fe7b9fd8254d28ad50b8714 (diff) | |
| parent | b94b0552f81e667bec31352901bbc8c76f1b4216 (diff) | |
Merge branch 'main' into nats-structs-discord-gateway
Diffstat (limited to 'webhook/src/handler/error.rs')
| -rw-r--r-- | webhook/src/handler/error.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/webhook/src/handler/error.rs b/webhook/src/handler/error.rs new file mode 100644 index 0000000..ccec59f --- /dev/null +++ b/webhook/src/handler/error.rs @@ -0,0 +1,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() + } +} |
