Skip to content

Commit 6d5f4e6

Browse files
authored
feat: improve error handling in SDKClient.executeTransaction to preserve original error details (#4376)
Signed-off-by: nikolay <[email protected]>
1 parent eb4d8a5 commit 6d5f4e6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

packages/relay/src/lib/clients/sdkClient.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,7 @@ export class SDKClient {
329329
}
330330

331331
if (!transactionResponse) {
332-
// Transactions may experience "SDK timeout exceeded" or "Connection Dropped" errors from the SDK, yet they may still be able to reach the consensus layer.
333-
// Throw Connection Drop and Timeout errors as additional handling logic is expected in a higher layer.
334-
if (sdkClientError.isConnectionDropped() || sdkClientError.isTimeoutExceeded()) {
335-
throw sdkClientError;
336-
} else {
337-
throw predefined.INTERNAL_ERROR(
338-
`Transaction execution returns a null value: transactionId=${transaction.transactionId}, callerName=${callerName}, txConstructorName=${txConstructorName}`,
339-
);
340-
}
332+
throw sdkClientError;
341333
}
342334
return transactionResponse;
343335
} finally {

packages/relay/tests/lib/sdkClient.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,22 @@ describe('SdkClient', async function () {
435435
await expect(callSubmit(buffer)).to.be.rejectedWith(SDKClientError, 'No fileId created for transaction.');
436436
});
437437
});
438+
439+
it('should wrap every error in a SDKClientError if transaction execution fails', async () => {
440+
sinon.stub(EthereumTransaction.prototype, 'execute').throwsException();
441+
442+
expect(
443+
sdkClient.executeTransaction(
444+
new EthereumTransaction().setCallDataFileId(fileId).setEthereumData(transactionBuffer),
445+
mockedCallerName,
446+
requestDetails,
447+
true,
448+
randomAccountAddress,
449+
),
450+
).to.eventually.be.rejected.and.satisfy((err: any) => {
451+
expect(err?.constructor?.name).to.equal(SDKClientError.constructor.name);
452+
});
453+
});
438454
});
439455

440456
describe('HBAR Limiter', async () => {

0 commit comments

Comments
 (0)