Functions
isProgramError
isProgramError<
TProgramErrorCode
>(error
,transactionMessage
,programAddress
,code?
):error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> & SolanaError<4615026>
Identifies whether an error -- typically caused by a transaction failure -- is a custom program error from the provided program address.
Type Parameters
Type Parameter |
---|
TProgramErrorCode extends number |
Parameters
Parameter | Type | Description |
---|---|---|
error | unknown | - |
transactionMessage | { instructions : Record <number , { programAddress : Address ; }>; } | The transaction message that failed to execute. Since the RPC response only provides the index of the failed instruction, the transaction message is required to determine its program address |
transactionMessage.instructions | Record <number , { programAddress : Address ; }> | - |
programAddress | Address | The address of the program from which the error is expected to have originated |
code? | TProgramErrorCode | The expected error code of the custom program error. When provided, the function will check that the custom program error code matches the given value. |
Returns
error is Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> & SolanaError<4615026>