Skip to content

Commit

Permalink
chore: log
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed May 19, 2024
1 parent 9cb044d commit b1632f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions frb_example/flutter_via_create/rust/src/api/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pub fn greet(name: String) -> String {

#[flutter_rust_bridge::frb(init)]
pub fn init_app() {
flutter_rust_bridge::console_error!("hi call simple::init_app START");
// Default utilities - feel free to customize
flutter_rust_bridge::setup_default_user_utils();
flutter_rust_bridge::console_error!("hi call simple::init_app END");
}
3 changes: 2 additions & 1 deletion frb_example/flutter_via_create/rust/src/frb_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ fn wire__crate__api__simple__init_app_impl(
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
deserializer.end();
flutter_rust_bridge::console_error!("hi call wire__crate__api__simple__init_app_impl INSIDE");
flutter_rust_bridge::console_error!("hi call wire__crate__api__simple__init_app_impl INSIDE 1");
move |context| {
flutter_rust_bridge::console_error!("hi call wire__crate__api__simple__init_app_impl INSIDE 2");
transform_result_sse(
(move || Result::<_, ()>::Ok(crate::api::simple::init_app()))(),
)
Expand Down
8 changes: 8 additions & 0 deletions frb_rust/src/handler/implementation/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::thread_pool::BaseThreadPool;
use std::future::Future;
use std::panic;
use std::panic::AssertUnwindSafe;
use crate::console_error;

/// The default handler used by the generated code.
pub type DefaultHandler<TP> =
Expand Down Expand Up @@ -165,16 +166,23 @@ impl<E: Executor, EL: ErrorListener> SimpleHandler<E, EL> {
// ref https://doc.rust-lang.org/nomicon/unwinding.html
let _ = panic::catch_unwind(AssertUnwindSafe(move || {
let task_info2 = task_info.clone();
console_error!("hi wrap_normal_or_async 1");
if let Err(error) = PanicBacktrace::catch_unwind(AssertUnwindSafe(move || {
console_error!("hi wrap_normal_or_async 2");
let task = prepare();
console_error!("hi wrap_normal_or_async 3");
execute(task_info2, task);
console_error!("hi wrap_normal_or_async 4");
})) {
console_error!("hi wrap_normal_or_async 5");
handle_non_sync_panic_error::<Rust2DartCodec>(
self.error_listener,
task_info.port.unwrap(),
error,
);
console_error!("hi wrap_normal_or_async 6");
}
console_error!("hi wrap_normal_or_async 7");
}));
}
}

0 comments on commit b1632f2

Please sign in to comment.