Catch Errors in JavaScript¶
Works in any browser game that uses the GameFuse JavaScript SDK (PlayCanvas, PixiJS, BabylonJS, Phaser, plain canvas).
That is all. Uncaught errors (window error events) and unhandled promise rejections now show up on your game's Errors tab.
Options¶
GameFuse.catchErrors({
release: "1.0.3", // your game's version, shown with each error
captureConsoleErrors: true, // also send console.error(...) calls (default false)
});
Send one yourself¶
An Error or a message, plus any details you want to see with it. This works without catchErrors(), but needs setUpGame.
try {
loadLevel(3);
} catch (e) {
GameFuse.sendError(e, { level: 3 });
}
GameFuse.sendError("Shop returned no items");
How it is sent¶
- Each error is first saved in
localStorage(keygamefuse_errors_<gameId>), then sent in a batch about 2 seconds later. - If it could not be sent (the player was offline, or the page was closed first), it is sent the next time the game calls
catchErrors(), marked as from the last session. - At most 50 errors wait, at most 30 are sent a minute, and the same error at most 5 times a minute.
- It fills in the page address, the browser and operating system, and the signed-in GameFuse player.
- It never throws into your game and never reports its own failures.
Files¶
It is in gameFuseFull.js and gameFuseFull.min.js. With the separate files, add V3/gameFuseErrors.js after V3/gameFuseUser.js and V3/gameFuse.js.