Final Platform Layer 0.9.8-beta
Loading...
Searching...
No Matches
Error handling

Check platform result

Use fplGetPlatformResult() to query the current platform result.
This is useful to check if fplPlatformInit() was already called or not. Also, this is useful to see which system failed in fplPlatformInit() .

Example:

switch (resultType) {
printf("Platform is not initialized yet!");
break;
printf("The audio system failed to initialize: %s", fplGetLastError());
break;
}
fpl_common_api const char * fplGetLastError()
Gets the last internal error string.
fpl_common_api fplPlatformResultType fplGetPlatformResult()
Gets the result type of the platform initialization.
fplPlatformResultType
An enumeration of platform result types.
@ fplPlatformResultType_FailedAudio
Audio initialization failed.
@ fplPlatformResultType_NotInitialized
Platform is not initialized.
Note
You may combine fplGetPlatformResult() with fplGetLastError, to get a more understanding of what exactly went wrong.

Get latest error

In case something goes wrong you can always call fplGetLastError() - at any time, regardless if it is initialized or not.
This either returns an empty string indicating everything is fine or a formatted string with a valid error message.

Example:

const char *errStr = fplGetLastError();
// Do something with the error string

Was there an error?

If you just want to check if there was an error, you can call fplGetErrorCount() to use the number of errors as a condition.

Example:

// Print out the error message
}
fpl_common_api size_t fplGetErrorCount()
Gets the count of total last errors.

Get error by index

Use fplGetErrorByIndex() to get a error string for the given index in range fplGetErrorCount() .

Example:

size_t errorCount = fplGetErrorCount();
if (errorCount > 0) {
const char *lastError = fplGetErrorByIndex(errorCount - 1);
// Do something with the last error
}
fpl_common_api const char * fplGetErrorByIndex(const size_t index)
Gets the last error string from the given index.

Clearing the errors

Errors will never be cleared by FPL! You have to do this yourself using fplClearErrors() .

Example:

fpl_common_api void fplClearErrors()
Clears all the current errors in the platform.