I think the most proper API to handle failures is to return a second integer error code in your api like:
int myfunc(args, int* realReturn);
The returned int is an error code.
The previous output is passed as a pointer in calling code:
int myInt;
if (myFunc(args, &myInt) != 0) {
//handle error
}