C++ Error Handling (Status API)
Include Au/Status.hh for the Status class:
Au::Status status = someOperation();
if (!status.ok()) {
// Handle error
std::cerr << "Error: " << status.message() << std::endl;
}
C Error Handling
Most C API functions return int status codes. Always check return values:
int result = au_cpuid_is_amd(0);
if (result < 0) {
// Error occurred
}
Common Error Scenarios:
CPU Detection Failures: Non-AMD CPUs will report correctly (not an error). Pre-Zen AMD CPUs may have limited support.
Thread Pinning Failures: Insufficient permissions (needs CAP_SYS_NICE on some Linux systems), invalid core numbers, or thread already terminated.
Logger Errors: File write permissions for file-based logging, or thread safety issues if logger is not properly initialized.
Best Practices:
Always check return values from C APIs
Use Status API in C++ for rich error information
Log errors for post-mortem analysis
Fail gracefully (don’t crash) on utility errors