aboutsummaryrefslogtreecommitdiff
path: root/error/include/error.h
blob: 92c06ffbea2e691a3e090d28f33938e9c561be93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include <cstring.h>
#include <stdio.h>

/// Get the last error.
const char* get_error(void);

extern xlstring gfx_error;

/// Set the last error.
#define set_error(...) \
  gfx_error.length = snprintf(gfx_error.str, xlstring_size, __VA_ARGS__)

/// Prepend an error to the last error.
#define prepend_error(...)                                        \
  {                                                               \
    xlstring head;                                                \
    head.length = snprintf(head.str, xlstring_size, __VA_ARGS__); \
    xlstring_append(&head, xlstring_make(": "));                  \
    gfx_error = xlstring_concat(head, gfx_error);                 \
  }