File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
itest/rust/src/object_tests Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,11 @@ impl CallError {
301
301
302
302
#[ doc( hidden) ]
303
303
pub fn failed_by_user_panic ( call_ctx : & CallContext , reason : String ) -> Self {
304
- Self :: new ( call_ctx, reason, None )
304
+ // This can cause the panic message to be printed twice in some scenarios (e.g. bind_mut() borrow failure).
305
+ // But in other cases (e.g. itest `dynamic_call_with_panic`), it is only printed once.
306
+ // Would need some work to have a consistent experience.
307
+
308
+ Self :: new ( call_ctx, format ! ( "function panicked: {reason}" ) , None )
305
309
}
306
310
307
311
fn new (
Original file line number Diff line number Diff line change @@ -296,11 +296,14 @@ where
296
296
297
297
let message = format_panic_message ( panic_info) ;
298
298
if godot_print ( ) {
299
+ // Also prints to stdout/stderr -- do not print twice.
299
300
godot_error ! ( "{message}" ) ;
301
+ } else {
302
+ eprintln ! ( "{message}" ) ;
300
303
}
301
304
302
305
let backtrace = format_backtrace ! ( "panic backtrace" ) ;
303
- eprintln ! ( "{message}{ backtrace}" ) ;
306
+ eprintln ! ( "{backtrace}" ) ;
304
307
let _ignored_result = std:: io:: stderr ( ) . flush ( ) ;
305
308
} ) ) ;
306
309
}
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ fn dynamic_call_with_panic() {
163
163
164
164
let expected_error_message = "godot-rust function call failed: Object::call(&\" do_panic\" )\
165
165
\n Source: ObjPayload::do_panic()\
166
- \n Reason: do_panic exploded"
166
+ \n Reason: function panicked: do_panic exploded"
167
167
. to_string ( ) ;
168
168
169
169
assert_eq ! ( call_error. to_string( ) , expected_error_message) ;
You can’t perform that action at this time.
0 commit comments