Better Errors
This commit is contained in:
parent
eb5db17652
commit
d55f485e03
4 changed files with 49 additions and 28 deletions
|
|
@ -360,8 +360,10 @@ impl AnonymousClientConnection {
|
||||||
let target_rho = match rho_manager::get_rho_con_for_user(receiver_id).await {
|
let target_rho = match rho_manager::get_rho_con_for_user(receiver_id).await {
|
||||||
Some(rho) => rho,
|
Some(rho) => rho,
|
||||||
_ => {
|
_ => {
|
||||||
self.send_error_response(&cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_not_found)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::receiver_id, DataValue::Number(receiver_id));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -394,13 +396,13 @@ impl AnonymousClientConnection {
|
||||||
DataValue::Str(id_str) => match Uuid::parse_str(&id_str.to_string()) {
|
DataValue::Str(id_str) => match Uuid::parse_str(&id_str.to_string()) {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.send_error_response(&cv.get_id(), CommunicationType::error)
|
self.send_error_response(&cv.get_id(), CommunicationType::error_invalid_call_id)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.send_error_response(&cv.get_id(), CommunicationType::error)
|
self.send_error_response(&cv.get_id(), CommunicationType::error_no_call_id)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -413,8 +415,10 @@ impl AnonymousClientConnection {
|
||||||
.add_data(DataTypes::call_token, DataValue::Str(token.to_string()));
|
.add_data(DataTypes::call_token, DataValue::Str(token.to_string()));
|
||||||
self.send_message(&response).await;
|
self.send_message(&response).await;
|
||||||
} else {
|
} else {
|
||||||
self.send_error_response(&cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_no_call_id)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::call_id, DataValue::Str(call_id.to_string()));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ impl AppConnection {
|
||||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||||
if self_clone2.get_rho_connection().await.is_none() {
|
if self_clone2.get_rho_connection().await.is_none() {
|
||||||
self_clone2
|
self_clone2
|
||||||
.send_error_response(0, CommunicationType::error)
|
.send_error_response(0, CommunicationType::error_no_iota)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -293,8 +293,10 @@ impl AppConnection {
|
||||||
msg_type,
|
msg_type,
|
||||||
msg_id
|
msg_id
|
||||||
);
|
);
|
||||||
self.send_error_response(msg_id, CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_no_iota)
|
||||||
.await;
|
.with_id(msg_id)
|
||||||
|
.add_data(DataTypes::user_id, DataValue::Number(sender_user_id as i64));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ impl ClientConnection {
|
||||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||||
if self_clone2.get_rho_connection().await.is_none() {
|
if self_clone2.get_rho_connection().await.is_none() {
|
||||||
self_clone2
|
self_clone2
|
||||||
.send_error_response(0, CommunicationType::error)
|
.send_error_response(0, CommunicationType::error_no_iota)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -290,8 +290,10 @@ impl ClientConnection {
|
||||||
let target_rho = match rho_manager::get_rho_con_for_user(receiver_id).await {
|
let target_rho = match rho_manager::get_rho_con_for_user(receiver_id).await {
|
||||||
Some(rho) => rho,
|
Some(rho) => rho,
|
||||||
_ => {
|
_ => {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_not_found)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::receiver_id, DataValue::Number(receiver_id));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -344,8 +346,10 @@ impl ClientConnection {
|
||||||
.add_data(DataTypes::call_token, DataValue::Str(token));
|
.add_data(DataTypes::call_token, DataValue::Str(token));
|
||||||
self.send_message(&response).await;
|
self.send_message(&response).await;
|
||||||
} else {
|
} else {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_no_call_id)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::call_id, DataValue::Str(call_id.to_string()));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -356,13 +360,13 @@ impl ClientConnection {
|
||||||
DataValue::Str(id_str) => match Uuid::parse_str(id_str.as_str()) {
|
DataValue::Str(id_str) => match Uuid::parse_str(id_str.as_str()) {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
self.send_error_response(cv.get_id(), CommunicationType::error_invalid_call_id)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
self.send_error_response(cv.get_id(), CommunicationType::error_no_call_id)
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -384,13 +388,17 @@ impl ClientConnection {
|
||||||
.add_data(DataTypes::user_ids, DataValue::Array(user_ids));
|
.add_data(DataTypes::user_ids, DataValue::Array(user_ids));
|
||||||
self.send_message(&response).await;
|
self.send_message(&response).await;
|
||||||
} else {
|
} else {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_invalid_user_id)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::user_id, DataValue::Number(user_id as i64));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_not_found)
|
||||||
.await;
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::call_id, DataValue::Str(call_id.to_string()));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -488,8 +496,11 @@ impl ClientConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.send_error_response(cv.get_id(), CommunicationType::error)
|
let path_data = cv.get_data(DataTypes::path).clone();
|
||||||
.await;
|
let error_cv = CommunicationValue::new(CommunicationType::error_not_found)
|
||||||
|
.with_id(cv.get_id())
|
||||||
|
.add_data(DataTypes::path, path_data);
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Forward message to Iota
|
/// Forward message to Iota
|
||||||
|
|
@ -599,8 +610,10 @@ impl ClientConnection {
|
||||||
msg_type,
|
msg_type,
|
||||||
msg_id
|
msg_id
|
||||||
);
|
);
|
||||||
self.send_error_response(msg_id, CommunicationType::error)
|
let error_cv = CommunicationValue::new(CommunicationType::error_no_iota)
|
||||||
.await;
|
.with_id(msg_id)
|
||||||
|
.add_data(DataTypes::user_id, DataValue::Number(sender_user_id as i64));
|
||||||
|
self.send_message(&error_cv).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,10 @@ impl GeneralConnection {
|
||||||
log_cv_out!(success_msg);
|
log_cv_out!(success_msg);
|
||||||
let _ = self.sender.send(&success_msg).await;
|
let _ = self.sender.send(&success_msg).await;
|
||||||
} else {
|
} else {
|
||||||
let err_msg =
|
let err_msg = CommunicationValue::new(
|
||||||
CommunicationValue::new(CommunicationType::error).with_id(cv.get_id());
|
CommunicationType::error_invalid_omikron_id,
|
||||||
|
)
|
||||||
|
.with_id(cv.get_id());
|
||||||
let _ = self.sender.send(&err_msg).await;
|
let _ = self.sender.send(&err_msg).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -356,7 +358,7 @@ impl GeneralConnection {
|
||||||
expected,
|
expected,
|
||||||
response
|
response
|
||||||
);
|
);
|
||||||
let err_msg = CommunicationValue::new(CommunicationType::error)
|
let err_msg = CommunicationValue::new(CommunicationType::error_invalid_challenge)
|
||||||
.with_id(cv.get_id())
|
.with_id(cv.get_id())
|
||||||
.add_data(
|
.add_data(
|
||||||
DataTypes::message,
|
DataTypes::message,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue