You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've confirmed that the error comes through to my frontend in the expected shape, but the specta bindings are incorrect. To resolve, I have to add #[serde(tag = "kind", content = "message")] to the Error declaration in addition to the ErrorKind declaration.
Lmk if I can provide any more info. Thanks for a great lib.
The text was updated successfully, but these errors were encountered:
Having to add #[serde(tag = "kind", content = "message")] to Error in addition to ErrorKind is to be expected - Specta only analyses field attributes, it can't know what custom Serialize implementation you have.
One trick you might be able to use is adding derive(Type) to ErrorKind, removing it from Error, then using #[specta(remote = Error)] on ErrorKind:
#[derive(Debug, thiserror::Error)]enumError{#[error("io error: {0}")]Io(String),#[error("failed to parse as string: {0}")]Utf8(String),}#[derive(serde::Serialize, specta::Type)]#[serde(tag = "kind", content = "message", rename_all = "camelCase")]#[specta(remote = Error)]enumErrorKind{Io(String),Utf8(String),}
Hello,
I've followed Tauri's suggested error handling implementation, and noticed an issue with specta's parsing of serde tags like so:
Here are my deps:
Reproduction here
On the left is actual, right is what I expect:
I've confirmed that the error comes through to my frontend in the expected shape, but the specta bindings are incorrect. To resolve, I have to add
#[serde(tag = "kind", content = "message")]
to theError
declaration in addition to theErrorKind
declaration.Lmk if I can provide any more info. Thanks for a great lib.
The text was updated successfully, but these errors were encountered: