feat: print program logs when transaction send fails (#13213)
This commit is contained in:
parent
413dfb01d5
commit
e7b7c15198
|
@ -2947,6 +2947,14 @@ export class Connection {
|
|||
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
||||
const res = SendTransactionRpcResult(unsafeRes);
|
||||
if (res.error) {
|
||||
if (res.error.data) {
|
||||
const logs = res.error.data.logs;
|
||||
if (logs && Array.isArray(logs)) {
|
||||
const traceIndent = '\n ';
|
||||
const logTrace = traceIndent + logs.join(traceIndent);
|
||||
console.error(res.error.message, logTrace);
|
||||
}
|
||||
}
|
||||
throw new Error('failed to send transaction: ' + res.error.message);
|
||||
}
|
||||
assert(typeof res.result !== 'undefined');
|
||||
|
|
Loading…
Reference in New Issue