From 67026729eb95500772f9b01b08bbe78822757fcf Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Tue, 3 Sep 2024 16:07:05 +0200 Subject: [PATCH] feat: allow transaction functions returning "any error" as string. In some cases, the transaction function cannot return any of the other errors variants easily. In such a case, having a "custom" (other) error type seems fine. --- src/goose.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/goose.rs b/src/goose.rs index e785b1a4..9d47f0e0 100644 --- a/src/goose.rs +++ b/src/goose.rs @@ -341,6 +341,8 @@ pub enum TransactionError { Reqwest(reqwest::Error), /// Wraps a [`url::ParseError`](https://docs.rs/url/*/url/enum.ParseError.html). Url(url::ParseError), + /// A generic, custom error in cases where the [`TransactionFunction`] cannot turn any of the others. + Custom(String), /// The request failed. RequestFailed { /// The [`GooseRequestMetric`](./struct.GooseRequestMetric.html) that failed. @@ -377,6 +379,7 @@ impl TransactionError { match *self { TransactionError::Reqwest(_) => "reqwest::Error", TransactionError::Url(_) => "url::ParseError", + TransactionError::Custom(_) => "custom error", TransactionError::RequestFailed { .. } => "request failed", TransactionError::RequestCanceled { .. } => { "request canceled because throttled load test ended"