Skip to content

Instantly share code, notes, and snippets.

@mortehu mortehu/error.c
Created Dec 11, 2014

What would you like to do?
Error reporting
static __thread char* last_error;
const char* last_error(void) {
return last_error ? last_error : strerror(errno);
void clear_error(void) {
last_error = NULL;
void set_error(const char* format, ...) {
va_list args;
va_start(args, format);
if (-1 == vasprintf(&last_error, format, args))
last_error = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.