passthroughFailedTransactionPlanExecution

Call Signature

function passthroughFailedTransactionPlanExecution(
    promise,
): Promise<SingleTransactionPlanResult>;

Wraps a transaction plan execution promise to return a TransactionPlanResult even on execution failure.

When a transaction plan executor throws a SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN error, this helper catches it and returns the TransactionPlanResult from the error context instead of throwing.

This allows us to handle the result of an execution in a single unified way instead of using try/catch and examine the TransactionPlanResult in both success and failure cases.

Any other errors are re-thrown as normal.

Parameters

ParameterTypeDescription
promisePromise<SingleTransactionPlanResult>A promise returned by a transaction plan executor.

Returns

Promise<SingleTransactionPlanResult>

A promise that resolves to the transaction plan result, even if some transactions failed.

Example

Handling failures using a single result object:

const result = await passthroughFailedTransactionPlanExecution(
  transactionPlanExecutor(transactionPlan)
);
 
const summary = summarizeTransactionPlanResult(result);
if (summary.successful) {
  console.log('All transactions executed successfully');
} else {
  console.log(`${summary.successfulTransactions.length} succeeded`);
  console.log(`${summary.failedTransactions.length} failed`);
  console.log(`${summary.canceledTransactions.length} canceled`);
}

See

Call Signature

function passthroughFailedTransactionPlanExecution(
    promise,
): Promise<TransactionPlanResult>;

Wraps a transaction plan execution promise to return a TransactionPlanResult even on execution failure.

When a transaction plan executor throws a SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN error, this helper catches it and returns the TransactionPlanResult from the error context instead of throwing.

This allows us to handle the result of an execution in a single unified way instead of using try/catch and examine the TransactionPlanResult in both success and failure cases.

Any other errors are re-thrown as normal.

Parameters

ParameterTypeDescription
promisePromise<TransactionPlanResult>A promise returned by a transaction plan executor.

Returns

Promise<TransactionPlanResult>

A promise that resolves to the transaction plan result, even if some transactions failed.

Example

Handling failures using a single result object:

const result = await passthroughFailedTransactionPlanExecution(
  transactionPlanExecutor(transactionPlan)
);
 
const summary = summarizeTransactionPlanResult(result);
if (summary.successful) {
  console.log('All transactions executed successfully');
} else {
  console.log(`${summary.successfulTransactions.length} succeeded`);
  console.log(`${summary.failedTransactions.length} failed`);
  console.log(`${summary.canceledTransactions.length} canceled`);
}

See

On this page