Skip to main content

Error handling

Mod installs fail for ordinary reasons: a player loses their connection mid-download, runs out of disk space, or edits a mod's files by hand. How your game handles those moments decides whether a player sees a clear message and a retry button, or a mod that silently never appears.

The SDK reports failures in a structured way, so your game can tell a temporary network problem from a request the server rejected, and show the player the right thing.

When a player reports a problem your team cannot reproduce, the SDK's log file is what makes it diagnosable. The log is off by default, so turning it on before launch is one of the cheapest support decisions you can make.

How failure is reported​

Calls that touch the network or the disk take a success delegate and a failure delegate, and in normal operation exactly one of them runs. If your success delegate throws, many calls catch the exception and run the failure delegate as well, so keep success delegates from throwing. What the failure delegate receives depends on the area:

AreaFailure delegate receives
LibraryCFCoreError
AuthenticationCFCoreError
CreationCFCoreError
Api and its nested membersApiResponseError
PremiumModsApiResponseError
ICFCore.InitializeA string message
Most CFUnity servicesA string message. See below

Some calls report failure differently:

SituationHow it is reported
Calling through an area member before initializationThe member is null, so the call throws a NullReferenceException in your own code
LocalCreationAsync methodsEach returns a Task. Failures surface as exceptions when you await it
Api.GetModDescriptionAsyncReturns a task that throws an ApiResponseException
Analytics methodsEach returns a bool immediately. There is no failure delegate

On CFUnity, LocalCreation returns Task objects, Analytics returns bool, and CFUnity.GetTerms passes a CFCoreError. CFUnity.Creation and CFUnity.LocalCreation throw an InvalidOperationException when the SDK is not initialized or the player is not signed in.

CFCoreError can wrap an ApiResponseError. When an authentication or creation call fails because of the API, the CFCoreError carries the API error inside it. Library calls are less consistent: an install that fails on a network request can arrive with the API error wrapped, but a failed download, a failed hash check or a failed disk write arrives as a description-only error.

Prebuilt UI: CFUnity and its services pass a single string to your error delegate, in most cases the error's Description. The error codes and flags are not available through them.

CFCoreError​

FieldTypeWhat it means
IsErrorboolUsually true. Do not rely on it, see below
ErrorCodeCFCoreErrorCodesThe kind of failure, when the SDK classifies it. See the reference below
DescriptionstringA readable description of what failed, when the SDK provides one
ApiErrorApiResponseErrorThe underlying API error, when there is one. Otherwise null
warning

A failure delegate running means the call failed, whatever the fields say. UploadCreation reports a missing file with IsError set to false. Most failures carry either a code or a description, rarely both: errors with a code, such as InstallCancelled or MissingInstalledMods, arrive with Description null, and errors without a code leave ErrorCode at None. Branch on the codes you handle, and fall back to Description, then to a generic message, for everything else.

ApiError is also set, with BadRequest, when Creation rejects input locally before sending anything, for example a missing upload file.

ApiResponseError​

ApiResponseError describes a failed request to the CurseForge API. Its flags say what kind of failure it was:

FlagSet when
CancelledThe request was cancelled, for example an aborted upload
ServerUnreachableThe server answered 500, 502, 503 or 504. See below
BadRequestThe server answered 400, or the SDK rejected the request before sending it
TokenExpiredThe server answered 401. The player's session is no longer valid
MissingPriviligesThe server answered 403: no session, or a session or API key without access
EntityNotFoundThe server answered 404
ResourceExpiredThe server answered 410. The resource expired
FailedToParseServerResponseThe response arrived but could not be read
FailedSignatureVerificationA signed premium response did not match your premium public key
PurchasePollingStoppedPurchase polling was stopped before ownership was confirmed
PurchasePollingTimeoutPurchase polling ran out of time before ownership was confirmed

The flag is spelled MissingPriviliges in the SDK. Use that spelling in your code.

warning

On Unity, a request that gets no response at all, for example while the player is offline, sets none of these flags. It arrives with every flag false and ErrorCode 0. Treat that combination as a connection failure.

Two more fields carry detail:

FieldTypeWhat it means
DescriptionstringA readable description. When the server returns its own message, this is that message
ErrorCodeintThe CurseForge API's own error code from the response, or 0 when there is none

ErrorCode identifies a specific rejection by the API.

Temporary failure versus rejection​

The two need opposite handling, and the fields tell them apart.

SignalWhat to do
No flag set and ErrorCode 0No response arrived. Keep the player's state and offer a retry later
ServerUnreachable setThe server failed to handle the request. Offer a retry later
ErrorCode not zeroThe API read the request and rejected it. Check the input before retrying
TokenExpired setSign the player in again, then repeat the call
Cancelled setYour own cancellation. Not a fault

Each API request times out after 10 seconds, so a request to an unreachable server can take that long before its failure delegate runs. Show progress in your interface rather than waiting on the result to update it.

Handling a failed install​

An install's failure delegate receives the CFCoreError and the InstalledMod it was working on, which is null when the install could not start. A cancelled install arrives with ErrorCode set to InstallCancelled. The sample also checks for a wrapped ApiResponseError whose Cancelled flag is set, which costs nothing and covers any other path.

How it works

  1. Check whether the install was cancelled, and if so, stop quietly.
  2. For an API failure, read the wrapped ApiResponseError flags.
  3. For anything else, including a failed download, a failed hash check or a failed disk write, log Description, which can be null, and show a generic message.
using Overwolf.CFCore.Base.Api.Models.Enums;
using Overwolf.CFCore.Base.Common;
using Overwolf.CFCore.Base.Library.Models;
using UnityEngine;

public class InstallErrorHandler : MonoBehaviour {
public void OnInstallFailed(CFCoreError error, InstalledMod mod) {
bool cancelled =
error.ErrorCode == CFCoreErrorCodes.InstallCancelled ||
error.ApiError?.Cancelled == true;
if (cancelled) {
return;
}

if (error.ErrorCode == CFCoreErrorCodes.ApiError &&
error.ApiError.ServerUnreachable) {
Debug.LogWarning("CurseForge is unreachable. Try again later.");
return;
}

Debug.LogError($"Install failed: {error.Description ?? error.ErrorCode.ToString()}");
}
}

Prebuilt UI: CFUnity.Install.RegisterInstallListener reports each state change with an error string.

CFCoreErrorCodes reference​

These are the codes the SDK raises. Switch on the named values, not on their numbers.

CodeWhat it means
NoneNo classification. On an error delivered to a failure delegate, read Description
ApiErrorThe failure came from the CurseForge API. Read ApiError
InstallCancelledThe install was cancelled
ModAlreadyBeingInstalledRarely raised. A second install of the same mod usually fails with None
NoPlatformFilesMatchedNo files for this platform matched the server's mod set
MissingInstalledModsOne or more mods in the server's mod set are not installed, or not with the required file
DetectedUnavailableModOn a server, one or more requested mods are unavailable on CurseForge
ModsNotOwnedByUserOne or more mods are premium and the player does not own them

The last four come from matching mod sets between a server and its clients. See Multiplayer and servers.

CFCoreErrorCodes also declares values the current SDK never raises. Do not write handling that depends on them. A failed download, a failed hash check and a failed disk write are among the failures that arrive with ErrorCode set to None, so read Description for those.

Logging​

The SDK writes its own log, separately from the errors it reports to your code. Logging is off by default.

Logger.Output valueWhere log lines go
NoneNowhere. The default
FileRolling log files in a logs folder inside the user data directory
ConsoleThe Unity console

LogOutput is a flags enum, so you can combine File and Console. Logger.History sets how many rolled files to keep, 8 by default and at most 30, and Logger.MaxSizeInMB sets the size at which a file rolls over, from 2 to 10 with 2 as the default. Each line is written at one of three levels: log, warning or error.

tip

Turn on file output in builds that reach players. When a player reports a failed install, the SDK's log file is usually what explains it.

With the settings asset, the same values are set on the CurseForge Settings page. The page's Logging Verbosity field only filters the console messages that CFUnity and its services write, which appear only when the output includes Console. It does not change the core SDK log. Full settings reference on Initialization and settings.

When to escalate​

If an error keeps recurring with a non-zero API ErrorCode you cannot resolve, or with FailedToParseServerResponse, send the error fields and the SDK log file to cfforstudios@overwolf.com.