feat: print program logs when transaction send fails (#13213)

This commit is contained in:
Justin Starry
2020-10-29 08:59:16 +08:00
committed by GitHub
parent 413dfb01d5
commit e7b7c15198

View File

@ -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');