fixed client crashing upon having bandwidth revoked

This commit is contained in:
Jędrzej Stuczyński
2024-07-23 12:07:43 +01:00
parent 78ca539018
commit db1ad4dcab
6 changed files with 416 additions and 237 deletions
@@ -26,7 +26,7 @@ use nym_credentials_interface::CredentialSpendingData;
use nym_gateway_requests::models::CredentialSpendingRequest;
use nym_gateway_requests::{
types::{BinaryRequest, ServerResponse},
ClientControlRequest, GatewayRequestsError,
ClientControlRequest, GatewayRequestsError, SimpleGatewayRequestsError,
};
use nym_sphinx::forwarding::packet::MixPacket;
use nym_task::TaskClient;
@@ -106,7 +106,19 @@ pub enum RequestHandlingError {
impl RequestHandlingError {
fn into_error_message(self) -> Message {
ServerResponse::new_error(self.to_string()).into()
let server_response = match self {
RequestHandlingError::OutOfBandwidth {
required,
available,
} => ServerResponse::TypedError {
error: SimpleGatewayRequestsError::OutOfBandwidth {
required,
available,
},
},
other => ServerResponse::new_error(other.to_string()),
};
server_response.into()
}
}