feat: print program logs when transaction send fails (#13213)
This commit is contained in:
@ -2947,6 +2947,14 @@ export class Connection {
|
|||||||
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
||||||
const res = SendTransactionRpcResult(unsafeRes);
|
const res = SendTransactionRpcResult(unsafeRes);
|
||||||
if (res.error) {
|
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);
|
throw new Error('failed to send transaction: ' + res.error.message);
|
||||||
}
|
}
|
||||||
assert(typeof res.result !== 'undefined');
|
assert(typeof res.result !== 'undefined');
|
||||||
|
Reference in New Issue
Block a user