Final Platform Layer 0.9.8-beta
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() .


switch (resultType) {
printf("Platform is not initialized yet!");
printf("The audio system failed to initialize: %s", fplGetLastError());
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.
An enumeration of platform result types.
@ fplPlatformResultType_FailedAudio
Audio initialization failed.
@ fplPlatformResultType_NotInitialized
Platform is not initialized.
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.


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.


// 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() .


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() .


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