diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9c3c94ee..0da55978d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,6 +114,7 @@ The minor version will be incremented upon a breaking change and the patch versi - idl: Fix missing `program::seed` resolution ([#3474](https://github.com/coral-xyz/anchor/pull/3474)). - lang: Fix adding `derive`s and `repr`s to type alias definitions in `declare_program!` ([#3504](https://github.com/coral-xyz/anchor/pull/3504)). - idl: Fix using constant identifiers as generic arguments ([#3522](https://github.com/coral-xyz/anchor/pull/3522)). +- client: Remove `std::process::exit` usage ([#3544](https://github.com/coral-xyz/anchor/pull/3544)). ### Breaking diff --git a/client/src/lib.rs b/client/src/lib.rs index a46def3de7..efd1eb23bb 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -345,7 +345,7 @@ impl + Clone> Program { signature: logs.value.signature.parse().unwrap(), slot: logs.context.slot, }; - let events = parse_logs_response(logs, &program_id_str); + let events = parse_logs_response(logs, &program_id_str)?; for e in events { f(&ctx, e); } @@ -672,7 +672,7 @@ impl + Clone, S: AsSigner> RequestBuilder<'_, C, fn parse_logs_response( logs: RpcResponse, program_id_str: &str, -) -> Vec { +) -> Result, ClientError> { let mut logs = &logs.value.logs[..]; let mut events: Vec = Vec::new(); if !logs.is_empty() { @@ -685,10 +685,7 @@ fn parse_logs_response( // Parse the log. let (event, new_program, did_pop) = { if program_id_str == execution.program() { - handle_program_log(program_id_str, l).unwrap_or_else(|e| { - println!("Unable to parse log: {e}"); - std::process::exit(1); - }) + handle_program_log(program_id_str, l)? } else { let (program, did_pop) = handle_system_log(program_id_str, l); (None, program, did_pop) @@ -727,7 +724,7 @@ fn parse_logs_response( } } } - events + Ok(events) } #[cfg(test)] @@ -856,7 +853,7 @@ mod tests { // No events returned here. Just ensuring that the function doesn't panic // due an incorrectly emptied stack. - let _: Vec = parse_logs_response( + parse_logs_response::( RpcResponse { context: RpcResponseContext::new(0), value: RpcLogsResponse { @@ -866,7 +863,8 @@ mod tests { }, }, program_id_str, - ); + ) + .unwrap(); Ok(()) }