-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsem-Except.hpp
58 lines (42 loc) · 1.17 KB
/
Asem-Except.hpp
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Asem-Except.hpp
* Author: etf
*
* Created on June 3, 2018, 10:08 AM
*/
#ifndef ASEM_EXCEPT_HPP
#define ASEM_EXCEPT_HPP
#include <exception>
#include <string>
namespace asem {
class SyntaxError : public std::exception {
std::string message;
size_t line_ord;
public:
SyntaxError(size_t line_ord, const std::string& msg) {
message = std::string("Syntax error near line ") +
std::to_string(line_ord) +
": " + msg;
}
SyntaxError(size_t line_ord, const char * msg) {
message = std::string("Syntax error near line ") +
std::to_string(line_ord) +
": " + msg;
}
const char* what() const noexcept {
return message.c_str();
}
SyntaxError(const SyntaxError & other) {
message = other.message;
}
SyntaxError & operator=(const SyntaxError & other) noexcept {
message = other.message;
}
};
}
#endif /* ASEM_EXCEPT_HPP */