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.
See isSimulationError for the list of error codes considered simulation errors.
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.