passthroughFailedTransactionPlanExecution

Call Signature

function passthroughFailedTransactionPlanExecution(promise): Promise<Readonly<{
  kind: "single";
  message: Readonly<{
     instructions: readonly Instruction<string, readonly (
        | AccountLookupMeta<..., ...>
       | AccountMeta<...>)[]>[];
     version: TransactionVersion;
  }> & TransactionMessageWithFeePayer<string>;
  status: TransactionPlanResultStatus<TransactionPlanResultContext>;
}>>;

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<Readonly<{ kind: "single"; message: Readonly<{ instructions: readonly Instruction<string, readonly ( | AccountLookupMeta<..., ...> | AccountMeta<...>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string>; status: TransactionPlanResultStatus<TransactionPlanResultContext>; }>>A promise returned by a transaction plan executor.

Returns

Promise<Readonly<{ kind: "single"; message: Readonly<{ instructions: readonly Instruction<string, readonly ( | AccountLookupMeta<..., ...> | AccountMeta<...>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string>; status: TransactionPlanResultStatus<TransactionPlanResultContext>; }>>

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