psmap: fix error handling when using transforms and attribute parsing

This commit is contained in:
Matt Bilker 2019-12-04 08:04:35 +00:00
parent 6120716be6
commit 3da94cc2e5
No known key found for this signature in database
GPG Key ID: 69ADF8AEB6C8B5D1
4 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "psmap"
version = "1.0.0"
version = "1.1.0"
authors = ["Matt Bilker <me@mbilker.us>"]
license = "MIT"
edition = "2018"
@ -8,4 +8,4 @@ edition = "2018"
[dependencies]
kbinxml = { path = "../kbinxml" }
psmap_derive = { path = "../psmap_derive" }
thiserror = "1.0.4"
thiserror = "1.0.9"

View File

@ -1,4 +1,5 @@
use kbinxml::KbinError;
use std::error::Error;
use thiserror::Error;
// Re-export proc macro
@ -18,7 +19,7 @@ pub enum PsmapError {
attribute: &'static str,
source_name: &'static str,
struct_name: &'static str,
source: KbinError,
source: Box<dyn Error + Send + Sync>,
},
#[error("Field `{target}` not found for `{struct_name}`")]

View File

@ -1,6 +1,6 @@
[package]
name = "psmap_derive"
version = "1.0.0"
version = "1.1.0"
authors = ["Matt Bilker <me@mbilker.us>"]
license = "MIT"
edition = "2018"

View File

@ -430,11 +430,11 @@ impl PsmapOutput {
attribute: #attr,
source_name: #source,
struct_name: stringify!(#struct_name),
source,
source: Box::new(source),
})?);
});
self.fields.append_all(quote_spanned! {target.span()=>
#target: #target.ok_or_else(::psmap::PsmapError::FieldNotFoundFromSource {
#target: #target.ok_or(::psmap::PsmapError::FieldNotFoundFromSource {
target: stringify!(#target),
source_name: #source,
struct_name: stringify!(#struct_name),