Improve the error message

Related #327
This commit is contained in:
Kevin Yue
2024-03-23 20:05:54 +08:00
parent 558485f5a9
commit 08bd4efefa
4 changed files with 42 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
use anyhow::bail;
use log::info;
use log::{info, warn};
use reqwest::{Client, StatusCode};
use roxmltree::Document;
use serde::Serialize;
@@ -8,7 +8,7 @@ use specta::Type;
use crate::{
gp_params::GpParams,
portal::PortalError,
utils::{base64, normalize_server, xml},
utils::{base64, normalize_server, parse_gp_error, xml},
};
const REQUIRED_PARAMS: [&str; 8] = [
@@ -126,6 +126,10 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result<Prel
}
if status.is_client_error() || status.is_server_error() {
let (reason, res) = parse_gp_error(res).await;
warn!("Prelogin error: reason={}, status={}, response={}", reason, status, res);
bail!("Prelogin error: {}", status)
}