Skip to content

Commit

Permalink
Log errors during configuration validation
Browse files Browse the repository at this point in the history
  • Loading branch information
plcplc committed Nov 7, 2023
1 parent 88cdc85 commit 9c4499a
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions rust-connector-sdk/src/default_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,33 @@ where
.await
.and_then(JsonResponse::into_value)
.map_err(|e| match e {
SchemaError::Other(_) => (
StatusCode::INTERNAL_SERVER_ERROR,
Json(ValidateErrors::UnableToBuildSchema),
),
SchemaError::Other(err) => {
tracing::error!(
meta.signal_type = "log",
event.domain = "ndc",
event.name = "Unable to build schema",
name = "Unable to build schema",
body = %err,
error = true,
);
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(ValidateErrors::UnableToBuildSchema),
)
}
})?;
let resolved_config_bytes = serde_json::to_vec(&configuration).map_err(|e| {
let resolved_config_bytes = serde_json::to_vec(&configuration).map_err(|err| {
tracing::error!(
meta.signal_type = "log",
event.domain = "ndc",
event.name = "Unable to serialize validated configuration",
name = "Unable to serialize validated configuration",
body = %err,
error = true,
);
(
StatusCode::INTERNAL_SERVER_ERROR,
Json(ValidateErrors::JsonEncodingError(e.to_string())),
Json(ValidateErrors::JsonEncodingError(err.to_string())),
)
})?;
let resolved_configuration = general_purpose::STANDARD.encode(resolved_config_bytes);
Expand Down

0 comments on commit 9c4499a

Please sign in to comment.