aboutsummaryrefslogtreecommitdiffstats
path: root/src/bootstrap/errors.c
blob: d957cfa09cb6c2502f8e4f8b70dfa3113ed3d2f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "errors.h"

static const char* error_msgs[] = {
    [ERR_UNKNOWN] = "error: something unexpected happened",
    [ERR_UNMATCHED_STRING] = "error: unmatched string delimiter",
    [ERR_UNBALANCED_PAREN] = "error: unbalanced parentheses",
    [ERR_NOT_IMPLEMENTED] = "error: not implemented",
    [ERR_EOF_REACHED] = "error: EOF reached",
    [ERR_UNKNOWN_TOKEN] = "error: unknown token",
    [ERR_UNKNOWN_OBJ_TYPE] = "error: can't eval unknown object type",
    [ERR_NOT_A_SYMBOL] = "error: object is not a symbol",
    [ERR_SYMBOL_NOT_FOUND] = "error: symbol not found",
    [ERR_OBJ_NOT_CALLABLE] = "error: object is not callable",
    [ERR_NOT_ENOUGH_ARGS] = "error: not enough arguments",
    [ERR_TOO_MANY_ARGS] = "error: too many arguments",
    [ERR_WRONG_ARG_TYPE] = "error: wrong argument type",
    [ERR_DIVISION_BY_ZERO] = "error: division by zero",
};

static Error errors[ERR_MAX_NUMBER];
static size_t errors_n = 0;
static bool supress_errors = false;

void
error_push(Error error) {
    if (errors_n < ERR_MAX_NUMBER) {
        errors[errors_n++] = error;
    }
}