wiggle GuestError: improve Display of InFunc, InDataField
This commit is contained in:
@@ -139,10 +139,12 @@ impl witx::Bindgen for Rust<'_> {
|
|||||||
) {
|
) {
|
||||||
let rt = self.rt;
|
let rt = self.rt;
|
||||||
let wrap_err = |location: &str| {
|
let wrap_err = |location: &str| {
|
||||||
|
let modulename = self.module.name.as_str();
|
||||||
let funcname = self.funcname;
|
let funcname = self.funcname;
|
||||||
quote! {
|
quote! {
|
||||||
|e| {
|
|e| {
|
||||||
#rt::GuestError::InFunc {
|
#rt::GuestError::InFunc {
|
||||||
|
modulename: #modulename,
|
||||||
funcname: #funcname,
|
funcname: #funcname,
|
||||||
location: #location,
|
location: #location,
|
||||||
err: Box::new(#rt::GuestError::from(e)),
|
err: Box::new(#rt::GuestError::from(e)),
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ pub enum GuestError {
|
|||||||
BorrowCheckerOutOfHandles,
|
BorrowCheckerOutOfHandles,
|
||||||
#[error("Slice length mismatch")]
|
#[error("Slice length mismatch")]
|
||||||
SliceLengthsDiffer,
|
SliceLengthsDiffer,
|
||||||
#[error("In func {funcname}:{location}:")]
|
#[error("In func {modulename}::{funcname} at {location}: {err}")]
|
||||||
InFunc {
|
InFunc {
|
||||||
|
modulename: &'static str,
|
||||||
funcname: &'static str,
|
funcname: &'static str,
|
||||||
location: &'static str,
|
location: &'static str,
|
||||||
#[source]
|
#[source]
|
||||||
err: Box<GuestError>,
|
err: Box<GuestError>,
|
||||||
},
|
},
|
||||||
#[error("In data {typename}.{field}:")]
|
#[error("In data {typename}.{field}: {err}")]
|
||||||
InDataField {
|
InDataField {
|
||||||
typename: String,
|
typename: String,
|
||||||
field: String,
|
field: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user