I am able to see my custom error messages (defined on chain) when I call the [anchor] program using javascript client node client.js
:
error: {
errorCode: { code: 'MEOW', number: 6003 },
errorMessage: 'This account a custom err message that I have written',
comparedValues: undefined,
origin: { file: 'programs/helloworld/src/lib.rs', line: 46 }
},
the errorCode and errorMessage are especially helpful. How can I print those fields using Rust? Right now, I am only getting
Error: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1774 [5 log messages]
Caused by:
0: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1774 [5 log messages]
1: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1774 [5 log messages]
my rust client code follows this template:
fn main() -> Result<()> {
call_instruction()?,
Ok(())
}
fn call_instruction() -> Result <()> {
let program = ...;
let signature = program
.request()
.accounts(program::accounts::Test {
user: program.payer(),
}).args(program::instruction::Testing {}).send()?;
println!("Transaction signature: {:?}",signature);
Ok(())
}
In terminal, I have tried setting env variable RUSTLOG=solana_client=debug
before running cargo run
, but nothing happens :(
cargo run