mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 20:45:06 +08:00
加点error report
This commit is contained in:
parent
047cc110a4
commit
d8e40bfb4d
|
@ -100,13 +100,29 @@ macro_rules! call_py_func {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
if let Ok(py_func) = get_func($plugin.py_module.bind(py), $func_name) {
|
if let Ok(py_func) = get_func($plugin.py_module.bind(py), $func_name) {
|
||||||
if let Err(e) = py_func.call1($args) {
|
if let Err(py_err) = py_func.call1($args) {
|
||||||
let e = PyPluginError::FuncCallError(
|
let e = PyPluginError::FuncCallError(
|
||||||
e,
|
py_err,
|
||||||
$func_name.to_string(),
|
$func_name.to_string(),
|
||||||
$plugin_path.to_string_lossy().to_string(),
|
$plugin_path.to_string_lossy().to_string(),
|
||||||
);
|
);
|
||||||
event!(Level::WARN, "failed to call function<{}>: {:?}", $func_name, e);
|
event!(
|
||||||
|
Level::WARN,
|
||||||
|
"failed to call function<{}>: {}\ntraceback: {}",
|
||||||
|
$func_name,
|
||||||
|
e,
|
||||||
|
// 获取 traceback
|
||||||
|
match &e {
|
||||||
|
PyPluginError::FuncCallError(py_err, _, _) => match py_err.traceback_bound(py) {
|
||||||
|
Some(traceback) => match traceback.format() {
|
||||||
|
Ok(trace) => trace,
|
||||||
|
Err(trace_e) => format!("failed to format traceback: {:?}", trace_e),
|
||||||
|
},
|
||||||
|
None => "no traceback".to_string(),
|
||||||
|
},
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user