build(deps): bump error-stack from version 0.3.1 to 0.4.1 (#4188)

This commit is contained in:
Sanchith Hegde
2024-04-01 12:31:17 +05:30
committed by GitHub
parent cb2000b088
commit ea730d4ffc
286 changed files with 1361 additions and 2397 deletions

View File

@ -2,7 +2,7 @@ use std::sync::Arc;
use actix_web::http::StatusCode;
use common_utils::errors::ParsingError;
use error_stack::{IntoReport, Report, ResultExt};
use error_stack::{report, Report, ResultExt};
use router_env::logger;
use time::PrimitiveDateTime;
@ -71,7 +71,6 @@ impl ClickhouseClient {
.body(format!("{query}\nFORMAT JSON"))
.send()
.await
.into_report()
.change_context(ClickhouseError::ConnectionError)?;
logger::debug!(clickhouse_response=?response, query=?query, "Clickhouse response");
@ -79,16 +78,14 @@ impl ClickhouseClient {
response.text().await.map_or_else(
|er| {
Err(ClickhouseError::ResponseError)
.into_report()
.attach_printable_lazy(|| format!("Error: {er:?}"))
},
|t| Err(ClickhouseError::ResponseNotOK(t)).into_report(),
|t| Err(report!(ClickhouseError::ResponseNotOK(t))),
)
} else {
Ok(response
.json::<CkhOutput<serde_json::Value>>()
.await
.into_report()
.change_context(ClickhouseError::ResponseError)?
.data)
}
@ -149,7 +146,7 @@ where
{
fn load_row(row: Self::Row) -> common_utils::errors::CustomResult<T, QueryExecutionError> {
row.try_into()
.change_context(QueryExecutionError::RowExtractionFailure)
.map_err(|error| error.change_context(QueryExecutionError::RowExtractionFailure))
}
}
@ -188,11 +185,9 @@ impl TryInto<ApiLogsResult> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<ApiLogsResult, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse ApiLogsResult in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse ApiLogsResult in clickhouse results",
))
}
}
@ -200,11 +195,9 @@ impl TryInto<SdkEventsResult> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<SdkEventsResult, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventsResult in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventsResult in clickhouse results",
))
}
}
@ -212,11 +205,9 @@ impl TryInto<ConnectorEventsResult> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<ConnectorEventsResult, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse ConnectorEventsResult in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse ConnectorEventsResult in clickhouse results",
))
}
}
@ -224,11 +215,9 @@ impl TryInto<PaymentMetricRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<PaymentMetricRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse PaymentMetricRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse PaymentMetricRow in clickhouse results",
))
}
}
@ -236,11 +225,9 @@ impl TryInto<PaymentDistributionRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<PaymentDistributionRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse PaymentDistributionRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse PaymentDistributionRow in clickhouse results",
))
}
}
@ -248,11 +235,9 @@ impl TryInto<FilterRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<FilterRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse FilterRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse FilterRow in clickhouse results",
))
}
}
@ -260,11 +245,9 @@ impl TryInto<RefundMetricRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<RefundMetricRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse RefundMetricRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse RefundMetricRow in clickhouse results",
))
}
}
@ -272,22 +255,18 @@ impl TryInto<RefundFilterRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<RefundFilterRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse RefundFilterRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse RefundFilterRow in clickhouse results",
))
}
}
impl TryInto<DisputeMetricRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<DisputeMetricRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse DisputeMetricRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse DisputeMetricRow in clickhouse results",
))
}
}
@ -295,11 +274,9 @@ impl TryInto<DisputeFilterRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<DisputeFilterRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse DisputeFilterRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse DisputeFilterRow in clickhouse results",
))
}
}
@ -307,11 +284,9 @@ impl TryInto<ApiEventMetricRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<ApiEventMetricRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse ApiEventMetricRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse ApiEventMetricRow in clickhouse results",
))
}
}
@ -319,11 +294,9 @@ impl TryInto<LatencyAvg> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<LatencyAvg, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse LatencyAvg in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse LatencyAvg in clickhouse results",
))
}
}
@ -331,11 +304,9 @@ impl TryInto<SdkEventMetricRow> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<SdkEventMetricRow, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventMetricRow in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventMetricRow in clickhouse results",
))
}
}
@ -343,11 +314,9 @@ impl TryInto<SdkEventFilter> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<SdkEventFilter, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventFilter in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse SdkEventFilter in clickhouse results",
))
}
}
@ -355,11 +324,9 @@ impl TryInto<ApiEventFilter> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<ApiEventFilter, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse ApiEventFilter in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse ApiEventFilter in clickhouse results",
))
}
}
@ -367,11 +334,9 @@ impl TryInto<OutgoingWebhookLogsResult> for serde_json::Value {
type Error = Report<ParsingError>;
fn try_into(self) -> Result<OutgoingWebhookLogsResult, Self::Error> {
serde_json::from_value(self)
.into_report()
.change_context(ParsingError::StructParseFailure(
"Failed to parse OutgoingWebhookLogsResult in clickhouse results",
))
serde_json::from_value(self).change_context(ParsingError::StructParseFailure(
"Failed to parse OutgoingWebhookLogsResult in clickhouse results",
))
}
}
@ -379,11 +344,9 @@ impl ToSql<ClickhouseClient> for PrimitiveDateTime {
fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result<String, ParsingError> {
let format =
time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]")
.into_report()
.change_context(ParsingError::DateTimeParsingError)
.attach_printable("Failed to parse format description")?;
self.format(&format)
.into_report()
.change_context(ParsingError::EncodeError(
"failed to encode to clickhouse date-time format",
))