aboutsummaryrefslogtreecommitdiff
path: root/src/errmsg.hpp
blob: e8b2f5872d56aee8dbf0d824c425f226890c2e87 (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
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2015 Andrew Kelley
 *
 * This file is part of zig, which is MIT licensed.
 * See http://opensource.org/licenses/MIT
 */

#ifndef ZIG_ERRMSG_HPP
#define ZIG_ERRMSG_HPP

#include "buffer.hpp"
#include "list.hpp"

enum ErrColor {
    ErrColorAuto,
    ErrColorOff,
    ErrColorOn,
};

struct ErrorMsg {
    size_t line_start;
    size_t column_start;
    Buf *msg;
    Buf *path;
    Buf line_buf;

    ZigList<ErrorMsg *> notes;
};

void print_err_msg(ErrorMsg *msg, ErrColor color);

void err_msg_add_note(ErrorMsg *parent, ErrorMsg *note);
ErrorMsg *err_msg_create_with_offset(Buf *path, size_t line, size_t column, size_t offset,
        const char *source, Buf *msg);

ErrorMsg *err_msg_create_with_line(Buf *path, size_t line, size_t column,
        Buf *source, ZigList<size_t> *line_offsets, Buf *msg);

#endif