Skip to main content

Common Errors

Common Errors🙋‍♀️

HLP creates new incentive for players to engage in your game, but it also requires additional testing to ensure a great experience for the Player. There are a few commong test scenarios that you should test in your game. These errors will occur when trying to submit a play (either by using .play in the Typescript SDK or calling the Play endpoint for manual API integration) They are:

  1. The user has not connected a wallet.
  2. The user does not have enough funds to play the game at the payment tier selected.
  3. Haste API 500 error

Once you have written your error handling code (see below) you can test these scenarios manually.

  1. Login to your account and disconnect your wallet under My Account / Wallet in the Haste Arcade.
  2. You can change your spendable balance in Handcash to 0 to simulate having no funds.
  3. Manually throw an error in your code right after call to .play to simulate a 500 from the Haste API.

The following code snippet demonstrates a potential error handling strategy for backend and frontend code. The frontend code is based on a React frontend that is utilizing hooks.

Server Side Error Handling

try {
// Haste Service is simply a wrapper around the Typescript SDK, which is recommended.
await, leaderboardId);
} catch (err: unknown) {
const realError = err as Error;

let message =
"An error occurred while trying to start the game. Please try again later. You will not be charged.";
if (realError.message.includes("validate their email")) {
message =
"Please verify your account via email. Otherwise contact support.";
} else if (realError.message.includes("connect a wallet")) {
message = "Please connect your wallet in the Haste Arcade.";
} else if (realError.message.includes("funds")) {
message =
"Please go to your handcash wallet and adjust your spendable balance.";

throw new BadRequestError(message);

Frontend Error Handling

onClick={async () => {
try {
const response = await<PlayResult>(
gameServerPlayUrl, // the url of your game server's play endpoint
{ leaderboardId: selectedPaymentTier },
headers: {
Authorization: `Bearer ${bearerToken}`, // this bearer token would include the player id which can be decoded server side from the JWT
} catch (err: any) {