From 3b0b21f8d155075e81043316434ac37a0cadd7fc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 5 Apr 2021 20:27:42 +0200 Subject: refactor(web/converse): Use crimp instead of reqwest 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 --- web/converse/src/errors.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'web/converse/src/errors.rs') 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 = result::Result; @@ -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 for ConverseError { } } -impl From for ConverseError { - fn from(error: reqwest::Error) -> ConverseError { +impl From for ConverseError { + fn from(error: serde_json::Error) -> ConverseError { + ConverseError::Serialisation { error } + } +} + +impl From 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), } } } -- cgit 1.4.1