-
Notifications
You must be signed in to change notification settings - Fork 185
/
error.cpp
68 lines (57 loc) · 1.69 KB
/
error.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "taco/error.h"
#include <iostream>
#include <cstdlib>
using namespace std;
namespace taco {
TacoException::TacoException(std::string msg) : message(msg) {}
const char* TacoException::what() const noexcept {
return message.c_str();
}
ErrorReport::ErrorReport(const char *file, const char *func, int line,
bool condition, const char *conditionString,
Kind kind, bool warning)
: msg(NULL), file(file), func(func), line(line), condition(condition),
conditionString(conditionString), kind(kind), warning(warning) {
if (condition) {
return;
}
msg = new std::ostringstream;
switch (kind) {
case User:
if (warning) {
(*msg) << "Warning";
} else {
(*msg) << "Error";
}
(*msg) << " at " << file << ":" << line << " in " << func << ":" << endl;
break;
case Internal:
(*msg) << "Compiler bug";
if (warning) {
(*msg) << "(warning)";
}
(*msg) << " at " << file << ":" << line << " in " << func;
(*msg) << endl << "Please report it to developers";
if (conditionString) {
(*msg) << endl << " Condition failed: " << conditionString;
}
(*msg) << endl;
break;
case Temporary:
(*msg) << "Temporary assumption broken";
(*msg) << " at " << file << ":" << line << endl;
(*msg) << " Not supported yet, but planned for the future";
if (conditionString) {
(*msg) << endl << " Condition failed: " << conditionString;
}
(*msg) << endl;
break;
}
(*msg) << " ";
}
void ErrorReport::explodeWithException() {
TacoException e = TacoException(msg->str());
delete msg;
throw e;
}
}