5

So im getting erros when calling the function getParsedTransaction() for example form the RPC-Node which is an 502 (Gateway-Error)

How would one implement a way to catch the error in JS/TS since the code is not continuing its execution once this error occurs.

The current implemented try/catch block it not catching the error it stops somewhere in the solana/web3 lib.

try {
  return await this.connection.getSignaturesForAddress(
    new PublicKey(this.program_id),
    {
      before,
      limit: parseInt(process.env.TXLIMIT ?? "10"),
    },
    "finalized",
  )
} catch (error) {
  console.log(error);
}
1
  • experiencing same issue, catch doesn't always catch exception Commented Jun 10 at 8:11

1 Answer 1

3

All methods in Connection class in Solana/web3.js are implemented to throw errors if any after invocation of the method. You should be able to catch it, in your catch block.

Can you put an additional param for better debugging and make sure it's working?

e.g catch (error) { console.log("connection error", error) }

You can also throw the error in you local connection.ts in node_modules (web3/index.*.js bundle files) to make sure it's actually not handled in web3 library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.