Skip to content

Error handling 2

Finalspace edited this page May 29, 2026 · 2 revisions

Table of Contents

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:

 resultType = ();
switch (resultType) {
    case :
        printf("Platform is not initialized yet!");
        break;
    case :
        printf("The audio system failed to initialize: %s", ());
        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 = ();
// 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:

if (()) {
    // Print out the error message
}

Get error by index

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

Example:

size_t errorCount = ();
if (errorCount > 0) {
    const char *lastError = (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 fplErrorsClear() .

Example:

();

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally