Skip to content

Commit

Permalink
feat: nice msg
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Nov 21, 2023
1 parent d67b0c4 commit 9f0820f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frb_dart/lib/src/generalized_frb_rust_binding/_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class GeneralizedFrbRustBinding {
try {
_binding.store_dart_post_cobject(ffi.NativeApi.postCObject.cast());
} on ArgumentError catch (e, s) {
print('${e.runtimeType} ${e.name} ${e.message}');
TODO;
_userFriendlyDynamicLibraryErrorReporting(e, s);
rethrow;
}
}
Expand All @@ -36,3 +35,14 @@ class GeneralizedFrbRustBinding {
/// {@macro flutter_rust_bridge.only_for_generated_code}
void freeWireSyncReturn(WireSyncReturn val) => _binding.free_wire_sync_return(val);
}

void _userFriendlyDynamicLibraryErrorReporting(ArgumentError e, StackTrace s) {
final message = e.message;
if (message is String && message.contains('Failed to lookup symbol')) {
throw ArgumentError(
'$e\n'
'This is often because the Rust library is not loaded correctly.\n'
'Original stack trace: $s',
);
}
}

0 comments on commit 9f0820f

Please sign in to comment.