Skip to content

Commit 46f7b58

Browse files
committed
fix(bindings): rename ShoppingListError field to avoid Kotlin Exception clash
UniFFI maps Error enums to subclasses of kotlin.Exception, which already has a 'message: String?' property. A variant field named 'message' was generated as a conflicting declaration, causing Kotlin compilation to fail during Android packaging. Rename the field to 'reason' so UniFFI generates a proper override of Exception.message as a getter.
1 parent c7e55b4 commit 46f7b58

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

bindings/src/shopping_list.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use std::collections::HashSet;
1111
/// boundary, so we wrap string messages in a typed error enum.
1212
#[derive(Debug, thiserror::Error, uniffi::Error)]
1313
pub enum ShoppingListError {
14-
#[error("failed to parse shopping list: {message}")]
15-
Parse { message: String },
16-
#[error("failed to serialize shopping list: {message}")]
17-
Serialize { message: String },
14+
#[error("failed to parse shopping list: {reason}")]
15+
Parse { reason: String },
16+
#[error("failed to serialize shopping list: {reason}")]
17+
Serialize { reason: String },
1818
}
1919

2020
// ---------------------------------------------------------------------------
@@ -142,7 +142,7 @@ pub fn parse_shopping_list_impl(input: &str) -> Result<ShoppingList, ShoppingLis
142142
sl::parse(input)
143143
.map(|list| ShoppingList::from(&list))
144144
.map_err(|e| ShoppingListError::Parse {
145-
message: e.to_string(),
145+
reason: e.to_string(),
146146
})
147147
}
148148

@@ -151,10 +151,10 @@ pub fn write_shopping_list_impl(list: &ShoppingList) -> Result<String, ShoppingL
151151
let original = OriginalShoppingList::from(list);
152152
let mut buf = Vec::new();
153153
sl::write(&original, &mut buf).map_err(|e| ShoppingListError::Serialize {
154-
message: e.to_string(),
154+
reason: e.to_string(),
155155
})?;
156156
String::from_utf8(buf).map_err(|e| ShoppingListError::Serialize {
157-
message: e.to_string(),
157+
reason: e.to_string(),
158158
})
159159
}
160160

@@ -178,10 +178,10 @@ pub fn write_check_entry_impl(entry: &CheckEntry) -> Result<String, ShoppingList
178178
let original = OriginalCheckEntry::from(entry);
179179
let mut buf = Vec::new();
180180
sl::write_check_entry(&original, &mut buf).map_err(|e| ShoppingListError::Serialize {
181-
message: e.to_string(),
181+
reason: e.to_string(),
182182
})?;
183183
String::from_utf8(buf).map_err(|e| ShoppingListError::Serialize {
184-
message: e.to_string(),
184+
reason: e.to_string(),
185185
})
186186
}
187187

0 commit comments

Comments
 (0)