typedef struct
{
err_t error;
int error_line;
char *error_msg;
...
...
} thing_t;
// set out of range error
thing->error = THING_ERROR_OOR;
thing->error_line = __LINE__;
thing->error_msg = "outofrange"
You can grep on 'outofrange' and find where the error was set.I originally started doing that to mark 'bad' analog readings in process control equipment. I wrote my filters and control loops to be able to 'eat' occasional bad readings without barfing. Worked very well.