unwrapSimulationError
Extracts the underlying cause from a simulation-related error.
When a transaction simulation fails, the error is often wrapped in a
simulation-specific SolanaError. This function unwraps such errors
by returning the cause property, giving you access to the actual error
that triggered the simulation failure.
If the provided error is not a simulation-related error, it is returned unchanged.
The following error codes are considered simulation errors:
- SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE
- SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT
Parameters
| Parameter | Type | Description |
|---|---|---|
error | unknown | The error to unwrap. |
Returns
unknown
The underlying cause if the error is a simulation error, otherwise the original error.
Example
Unwrapping a preflight failure to access the root cause.