Include the whole error message in errors from Rust (#3415)
This commit is contained in:
committed by
GitHub
parent
d093ce3d84
commit
43ca74549d
@@ -1,7 +1,15 @@
|
|||||||
use crate::string::RustString;
|
use crate::string::RustString;
|
||||||
|
|
||||||
pub(crate) fn err_to_ruststring(e: impl std::string::ToString) -> RustString<'static> {
|
pub(crate) fn err_to_ruststring(e: anyhow::Error) -> RustString<'static> {
|
||||||
RustString::from(e.to_string())
|
// The default `to_string` representation of `anyhow::Error` only shows the "outermost"
|
||||||
|
// context, e.g., "Could not connect to server", and omits the juicy details about what
|
||||||
|
// actually went wrong. So, join all of those contexts with `: ` for presentation to the C++
|
||||||
|
// layer.
|
||||||
|
let entire_msg = e
|
||||||
|
.chain()
|
||||||
|
.skip(1)
|
||||||
|
.fold(e.to_string(), |a, b| format!("{}: {}", a, b));
|
||||||
|
RustString::from(entire_msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An implementation of Vec::into_raw_parts, which is still unstable. Returns ptr, len, cap.
|
/// An implementation of Vec::into_raw_parts, which is still unstable. Returns ptr, len, cap.
|
||||||
|
|||||||
Reference in New Issue
Block a user