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:
| Area | Failure delegate receives |
|---|---|
Library | CFCoreError |
Authentication | CFCoreError |
Creation | CFCoreError |
Api and its nested members | ApiResponseError |
PremiumMods | ApiResponseError |
ICFCore.Initialize | A string message |
Most CFUnity services | A string message. See below |
Some calls report failure differently:
| Situation | How it is reported |
|---|---|
| Calling through an area member before initialization | The member is null, so the call throws a NullReferenceException in your own code |
LocalCreationAsync methods | Each returns a Task. Failures surface as exceptions when you await it |
Api.GetModDescriptionAsync | Returns a task that throws an ApiResponseException |
Analytics methods | Each 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
| Field | Type | What it means |
|---|---|---|
IsError | bool | Usually true. Do not rely on it, see below |
ErrorCode | CFCoreErrorCodes | The kind of failure, when the SDK classifies it. See the reference below |
Description | string | A readable description of what failed, when the SDK provides one |
ApiError | ApiResponseError | The underlying API error, when there is one. Otherwise null |
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:
| Flag | Set when |
|---|---|
Cancelled | The request was cancelled, for example an aborted upload |
ServerUnreachable | The server answered 500, 502, 503 or 504. See below |
BadRequest | The server answered 400, or the SDK rejected the request before sending it |
TokenExpired | The server answered 401. The player's session is no longer valid |
MissingPriviliges | The server answered 403: no session, or a session or API key without access |
EntityNotFound | The server answered 404 |
ResourceExpired | The server answered 410. The resource expired |
FailedToParseServerResponse | The response arrived but could not be read |
FailedSignatureVerification | A signed premium response did not match your premium public key |
PurchasePollingStopped | Purchase polling was stopped before ownership was confirmed |
PurchasePollingTimeout | Purchase polling ran out of time before ownership was confirmed |
The flag is spelled MissingPriviliges in the SDK. Use that spelling in your code.
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:
| Field | Type | What it means |
|---|---|---|
Description | string | A readable description. When the server returns its own message, this is that message |
ErrorCode | int | The 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.
| Signal | What to do |
|---|---|
No flag set and ErrorCode 0 | No response arrived. Keep the player's state and offer a retry later |
ServerUnreachable set | The server failed to handle the request. Offer a retry later |
ErrorCode not zero | The API read the request and rejected it. Check the input before retrying |
TokenExpired set | Sign the player in again, then repeat the call |
Cancelled set | Your 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
- Check whether the install was cancelled, and if so, stop quietly.
- For an API failure, read the wrapped
ApiResponseErrorflags. - 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.
| Code | What it means |
|---|---|
None | No classification. On an error delivered to a failure delegate, read Description |
ApiError | The failure came from the CurseForge API. Read ApiError |
InstallCancelled | The install was cancelled |
ModAlreadyBeingInstalled | Rarely raised. A second install of the same mod usually fails with None |
NoPlatformFilesMatched | No files for this platform matched the server's mod set |
MissingInstalledMods | One or more mods in the server's mod set are not installed, or not with the required file |
DetectedUnavailableMod | On a server, one or more requested mods are unavailable on CurseForge |
ModsNotOwnedByUser | One 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 value | Where log lines go |
|---|---|
None | Nowhere. The default |
File | Rolling log files in a logs folder inside the user data directory |
Console | The 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.
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.