异常消息不打印堆栈信息, 该信息不应该向用户展示
This commit is contained in:
parent
8866fd8b02
commit
fd87bf7fce
27
src/main.rs
27
src/main.rs
@ -269,17 +269,28 @@ impl MainWindow {
|
|||||||
let label = self.label.clone();
|
let label = self.label.clone();
|
||||||
let download_type: DownloadType = self.selection.unwrap();
|
let download_type: DownloadType = self.selection.unwrap();
|
||||||
let online = self.is_online.clone();
|
let online = self.is_online.clone();
|
||||||
|
if label == ""{
|
||||||
|
add_log("请输入Label".to_string());
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let mut download_wrapper = download_wrapper::DownloadWrapper::new();
|
let mut download_wrapper = download_wrapper::DownloadWrapper::new();
|
||||||
let mut mes_service: MesService;
|
let mut mes_service: MesService;
|
||||||
if online {
|
if online {
|
||||||
add_log("当前为在线模式, 正在连接数据库".to_string());
|
add_log("当前为在线模式, 正在连接数据库".to_string());
|
||||||
mes_service = MesService::new(mes_config.ip.clone(), mes_config.port.clone(), mes_config.username.clone(), mes_config.password.clone(), mes_config.database.clone());
|
match MesService::new(mes_config.ip.clone(), mes_config.port.clone(), mes_config.username.clone(), mes_config.password.clone(), mes_config.database.clone()){
|
||||||
|
Ok(service) => mes_service = service,
|
||||||
|
Err(e) =>{
|
||||||
|
add_log(format!("连接数据库失败: {:?}", e.to_string()));
|
||||||
|
sender.send(Message::DownloadEnd(false)).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
add_log("连接成功".to_string());
|
add_log("连接成功".to_string());
|
||||||
add_log("正在过站检测".to_string());
|
add_log("正在过站检测".to_string());
|
||||||
let check_result = mes_service.check_station(mes_config.work_order.clone(), label.clone(), download_type);
|
let check_result = mes_service.check_station(mes_config.work_order.clone(), label.clone(), download_type);
|
||||||
if let Err(res) = check_result {
|
if let Err(res) = check_result {
|
||||||
add_log(format!("过站检测失败: {:?}", res));
|
add_log(format!("过站检测失败: {:?}", res.to_string()));
|
||||||
sender.send(Message::DownloadEnd(false)).unwrap();
|
sender.send(Message::DownloadEnd(false)).unwrap();
|
||||||
return;
|
return;
|
||||||
} else if let Ok(res) = check_result {
|
} else if let Ok(res) = check_result {
|
||||||
@ -343,11 +354,17 @@ impl MainWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return if online {
|
return if online {
|
||||||
mes_service = MesService::new(mes_config.ip, mes_config.port, mes_config.username, mes_config.password, mes_config.database);
|
match MesService::new(mes_config.ip.clone(), mes_config.port.clone(), mes_config.username.clone(), mes_config.password.clone(), mes_config.database.clone()){
|
||||||
add_log("正在上传数据".to_string());
|
Ok(service) => mes_service = service,
|
||||||
|
Err(e) =>{
|
||||||
|
add_log(format!("连接数据库失败: {:?}", e.to_string()));
|
||||||
|
sender.send(Message::DownloadEnd(false)).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} add_log("正在上传数据".to_string());
|
||||||
let update_result = mes_service.update_station(mes_config.work_order, label, download_type);
|
let update_result = mes_service.update_station(mes_config.work_order, label, download_type);
|
||||||
if let Err(e) = update_result {
|
if let Err(e) = update_result {
|
||||||
add_log(format!("上传失败: {:?}", e));
|
add_log(format!("上传失败: {:?}", e.to_string()));
|
||||||
sender.send(Message::DownloadEnd(false)).unwrap();
|
sender.send(Message::DownloadEnd(false)).unwrap();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ pub(crate) struct MesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MesService {
|
impl MesService {
|
||||||
pub fn new(ip: String, port: String, username: String, password: String, database: String) -> Self {
|
pub fn new(ip: String, port: String, username: String, password: String, database: String) -> Result<Self, Error> {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"mysql://{}:{}@{}:{}/{}",
|
"mysql://{}:{}@{}:{}/{}",
|
||||||
username, password, ip, port, database
|
username, password, ip, port, database
|
||||||
);
|
);
|
||||||
let pool = mysql::Pool::new(url.as_str()).unwrap();
|
let pool = mysql::Pool::new(url.as_str())?;
|
||||||
Self { pool }
|
Ok(Self { pool })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_work_orders(&self) -> Result<Vec<String>, Error> {
|
pub fn get_work_orders(&self) -> Result<Vec<String>, Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user