API ReferenceErrorsClass
PriceServerError
Error thrown when the SDK cannot get a usable price from the Pyth price service (Hermes). The
request failed, the service has no single price feed for the token, or it returned a price that
cannot be used, such as one whose confidence interval is as wide as the price. The underlying error
is its cause; error.walk(PriceFeedNotFoundError) tells a token with no feed apart from a
connection failure.
When a transaction needs a price update and this error occurs, the SDK uses the onchain oracle price instead if it can confirm that price is fresh. StalePythPriceError is a separate failure and never falls back.
Extends
Constructors
Constructor
new PriceServerError(cause): PriceServerError;Parameters
| Parameter | Type |
|---|---|
cause | unknown |
Returns
PriceServerError
Overrides
Methods
walk()
walk<T>(errorType): T | undefined;Finds an error of the given class in this error’s cause chain. The search starts with this error
itself, then follows each cause in turn.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends Error | The error class being searched for. |
Parameters
| Parameter | Type | Description |
|---|---|---|
errorType | (…args) => T | The error class to find, such as UserRejectedRequestError. |
Returns
T | undefined
The first error in the chain that is an instance of errorType, or undefined if there is none.
Example
const rejected = error.walk(UserRejectedRequestError);if (rejected) return; // the user declined in their wallet