-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBaseException.h
42 lines (30 loc) · 1002 Bytes
/
BaseException.h
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
/*=====================================================================
BaseException.h
---------------
Copyright Glare Technologies Limited 2019 -
=====================================================================*/
#pragma once
#include "wnt_Diagnostics.h"
#include <utils/Exception.h>
namespace Winter
{
class BaseException : public glare::Exception
{
public:
BaseException(const std::string& s) : glare::Exception(s) {}
virtual ~BaseException() {}
virtual std::string messageWithPosition() { return what(); } // Exception message, with source position info if there is some.
};
class ExceptionWithPosition : public BaseException
{
public:
ExceptionWithPosition(const std::string& s_, const BufferPosition& pos_) : BaseException(s_), _pos(pos_) {}
const BufferPosition& pos() const { return _pos; }
virtual std::string messageWithPosition()
{
return what() + Diagnostics::positionString(_pos);
}
private:
BufferPosition _pos;
};
}