diff options
author | Vincent Ambo <mail@tazj.in> | 2021-04-05T18·27+0200 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-04-05T19·19+0000 |
commit | 3b0b21f8d155075e81043316434ac37a0cadd7fc (patch) | |
tree | 8e89327cc3f4bd5ecf296c07463b9a2858d9de13 /web/converse/src/errors.rs | |
parent | 8fc4e083c9c5f1dce759461dc4c45e26151a3ad1 (diff) |
refactor(web/converse): Use crimp instead of reqwest r/2445
This simpler, curl-based HTTP client (which I wrote years ago) is a first step towards cleaning up the dependency mess of converse. Dependency stats: +4, -28 Change-Id: I4f5f3c9307895d261bfb0a6bcf2337b747f9a4c0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2859 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'web/converse/src/errors.rs')
-rw-r--r-- | web/converse/src/errors.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/web/converse/src/errors.rs b/web/converse/src/errors.rs index 6b22f8d39aa5..b079f41c4fff 100644 --- a/web/converse/src/errors.rs +++ b/web/converse/src/errors.rs @@ -31,7 +31,6 @@ use actix_web; use askama; use diesel; use r2d2; -use reqwest; use tokio_timer; pub type Result<T> = result::Result<T, ConverseError>; @@ -62,6 +61,9 @@ pub enum ConverseError { #[fail(display = "thread {} is closed and can not be responded to", id)] ThreadClosed { id: i32 }, + #[fail(display = "JSON serialisation failed: {}", error)] + Serialisation { error: serde_json::Error }, + // This variant is used as a catch-all for wrapping // actix-web-compatible response errors, such as the errors it // throws itself. @@ -103,10 +105,16 @@ impl From<actix_web::Error> for ConverseError { } } -impl From<reqwest::Error> for ConverseError { - fn from(error: reqwest::Error) -> ConverseError { +impl From<serde_json::Error> for ConverseError { + fn from(error: serde_json::Error) -> ConverseError { + ConverseError::Serialisation { error } + } +} + +impl From<curl::Error> for ConverseError { + fn from(error: curl::Error) -> ConverseError { ConverseError::InternalError { - reason: format!("Failed to make HTTP request: {}", error), + reason: format!("error during HTTP request: {}", error), } } } |