summaryrefslogtreecommitdiff
path: root/error.h
blob: 206afd85c197de47f10e26b53def7135ec83e6e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef ERROR_H
#define ERROR_H

#include <stdio.h>
#include <stdlib.h>

enum errcode {
    OK = 0,
    GENERAL_ERROR = 1,
    COMMAND_NOT_FOUND = 2,
    UNKNOWN_ID,
    SYNTAX_ERROR
};

/* FIXME: double fprintf is ugly */
#define error(v, ...) do { \
    fprintf(stderr, __VA_ARGS__); \
    fprintf(stderr, "\n"); \
    exit(v); \
} while (0)

#endif /* ERROR_H */