Skip to content
Download all docs .md

Catch Errors in Unity C

Needs the GameFuse Unity SDK (game-fuse-cs) 1.1 or newer.

GameFuse.SetUpGame(gameId, gameToken, OnSetUp);
GameFuse.CatchErrors();

That is all. From now on these show up on your game's Errors tab:

  • exceptions nobody caught (Unity logs them as LogType.Exception), plus AppDomain unhandled exceptions and unobserved Task exceptions;
  • errors: Debug.LogError and failed Debug.Assert calls;
  • crashes: on desktop builds, if the game did not close cleanly last time.

Options

GameFuse.CatchErrors(release: "1.0.3", captureLoggedErrors: false);
  • release: your game's version. Default Application.version.
  • captureLoggedErrors: set false to skip Debug.LogError and asserts and only send exceptions.

Send one yourself

try { LoadLevel(3); }
catch (Exception e) { GameFuse.SendError(e, new Dictionary<string, object> { { "level", 3 } }); }

GameFuse.SendError("Shop returned no items");

This works without CatchErrors(), but needs SetUpGame.

How it is sent

  • Each error is first saved in Application.persistentDataPath/GameFuse/pending-errors.json, then sent with UnityWebRequest about 2 seconds later (a crash is sent at once). It works on every platform, WebGL too.
  • What could not be sent (offline, or the game crashed first) is sent on the next start, 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 scene, SystemInfo.operatingSystem, SystemInfo.deviceModel and the signed-in GameFuse player.
  • Errors are collected from any thread; files and sending happen on the main thread. Call CatchErrors() from the main thread at start (in Awake or Start), so errors sent later from other threads have somewhere to go. It never throws into your game.
  • WebGL: errors are sent as usual. Ones left over from a crash are kept in the browser's storage, which Unity saves on its own from 2022.2 (older versions may lose them on reload).
  • Editor: it only runs in Play mode.