Final Platform Layer  0.9.6-beta
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;
}
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
}

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
}

Clearing the errors

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

Example:

fplPlatformResultType_FailedAudio
Audio initialization failed.
Definition: final_platform_layer.h:3417
fplPlatformResultType
fplPlatformResultType
An enumeration of platform result types.
Definition: final_platform_layer.h:3413
fplGetPlatformResult
fpl_common_api fplPlatformResultType fplGetPlatformResult()
Gets the result type of the platform initialization.
fplGetLastError
const fpl_common_api char * fplGetLastError()
Gets the last internal error string.
fplPlatformResultType_NotInitialized
Platform is not initialized.
Definition: final_platform_layer.h:3427
fplGetErrorCount
fpl_common_api size_t fplGetErrorCount()
Gets the count of total last errors.
fplClearErrors
fpl_common_api void fplClearErrors()
Clears all the current errors in the platform.
fplGetErrorByIndex
const fpl_common_api char * fplGetErrorByIndex(const size_t index)
Gets the last error string from the given index.