]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/glsl_error.h
0b4b4b02d2ddff4641f41b5c59ce2df6c1d110f7
[libs/gl.git] / source / glsl / glsl_error.h
1 #ifndef MSP_GL_SL_ERROR_H_
2 #define MSP_GL_SL_ERROR_H_
3
4 #include <stdexcept>
5 #include <msp/strings/format.h>
6
7 namespace Msp {
8 namespace GL {
9 namespace SL {
10
11 struct Location;
12
13 class invalid_shader_source: public std::runtime_error
14 {
15 public:
16         invalid_shader_source(const std::string &w): runtime_error(w) { }
17         invalid_shader_source(const Location &, const std::string &);
18 #if __cplusplus>=201103L
19         template<typename... Args>
20         invalid_shader_source(const Location &loc, const std::string & fmt, Args... args):
21                 invalid_shader_source(loc, format(fmt, args...))
22         { }
23 #endif
24         virtual ~invalid_shader_source() throw() { }
25 };
26
27 class syntax_error: public invalid_shader_source
28 {
29 public:
30         syntax_error(const Location &, const std::string &, const std::string &);
31         virtual ~syntax_error() throw() { }
32 };
33
34 class parse_error: public invalid_shader_source
35 {
36 public:
37         parse_error(const Location &, const std::string &, const std::string &);
38         virtual ~parse_error() throw() { }
39 };
40
41 class internal_error: public std::logic_error
42 {
43 public:
44         internal_error(const std::string &w): logic_error(w) { }
45         virtual ~internal_error() throw() { }
46 };
47
48 struct Diagnostic
49 {
50         enum Severity
51         {
52                 INFO,
53                 WARN,
54                 ERR
55         };
56
57         Severity severity;
58         int source;
59         unsigned line;
60         int provoking_source;
61         unsigned provoking_line;
62         std::string message;
63
64         Diagnostic();
65         Diagnostic(Severity, int, unsigned, const std::string &);
66 };
67
68 } // namespace SL
69 } // namespace GL
70 } // namespace Msp
71
72 #endif