Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): removed panicking code #293

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/web-plugins/didcomm-messaging/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub(crate) enum Error {
InternalServer,
#[error("unsupported content-type, only accept application/didcomm-encrypted+json")]
NotDidcommEncryptedPayload,
#[error("Could not unpack message")]
UnpackingError,
}

impl Error {
Expand Down
12 changes: 5 additions & 7 deletions crates/web-plugins/didcomm-messaging/src/midlw.rs
IngridPuppet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use http_body_util::BodyExt;
use hyper::Request;
use serde_json::Value;
use std::sync::Arc;
use tracing::error;

// use super::{error::MediationError, AppState};
use crate::{
Expand Down Expand Up @@ -80,7 +81,7 @@ pub async fn unpack_didcomm_message(

next.run(request).await
}
Err(response) => response,
Err(response) => response.into_response(),
}
Christiantyemele marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -119,13 +120,10 @@ async fn unpack_payload(
.await;

let (plain_message, metadata) = res.map_err(|err| {
tracing::error!("Failed to unpack message: {err:?}");
let response = (
StatusCode::INTERNAL_SERVER_ERROR,
Error::InternalServer.json(),
);
error!("Failed to unpack message: {}, {}", err.kind(), err.source);
let response = (StatusCode::BAD_REQUEST, Error::UnpackingError.json());

response.into_response()
return response.into_response();
})?;
Christiantyemele marked this conversation as resolved.
Show resolved Hide resolved

if !metadata.encrypted {
Expand Down
Loading