diff --git a/android/ffi/src/lib.rs b/android/ffi/src/lib.rs index 9022c31..0e2e682 100644 --- a/android/ffi/src/lib.rs +++ b/android/ffi/src/lib.rs @@ -58,6 +58,21 @@ uniffi::setup_scaffolding!(); /// working exactly as intended — and the UI's response is to offer linking, not to /// show an error. #[derive(Debug, thiserror::Error, uniffi::Error)] +// FLAT, so the Kotlin side gets the message on `Throwable` where it belongs. +// +// Without this, uniffi generates an exception subclass with a `message` PROPERTY +// per variant — which collides with `Throwable.message` and fails to compile: +// "'message' hides member of supertype 'Throwable' and needs an 'override' +// modifier". Renaming the field would dodge the collision but leave +// `e.message` null in Kotlin, so every call site would have to know the variant +// just to read the text. +// +// Flat keeps what actually matters: each variant is still its own Kotlin +// subclass, so `catch (e: CoreException.NotLinked)` still works and a `when` is +// still exhaustive. Only the FIELDS stop crossing, and the Display string — +// which is the field, for every variant that has one — comes through as the +// exception message. +#[uniffi(flat_error)] pub enum CoreError { /// No server is linked. Not a fault; the app is local-first and this is its /// resting state.