]> git.localhorst.tv Git - tacos.git/blob - src/app/error.cpp
the usual suspects
[tacos.git] / src / app / error.cpp
1 #include "error.hpp"
2
3 #include <alut.h>
4 #include <SDL.h>
5 #include <GL/glew.h>
6
7 using std::runtime_error;
8 using std::string;
9
10
11 namespace {
12
13 const char *sdl_error_flush() {
14         const char *err = SDL_GetError();
15         if (err && *err) {
16                 SDL_ClearError();
17         }
18         return err;
19 }
20
21 string error_append(string msg, const char *err) {
22         if (err && *err) {
23                 msg += ": ";
24                 msg += err;
25         }
26         return msg;
27 }
28
29 }
30
31 namespace tacos {
32
33 AlutError::AlutError(const char *msg)
34 : runtime_error(error_append(msg, alutGetErrorString(alutGetError()))) {
35
36 }
37
38
39 GLError::GLError(const char *msg)
40 : runtime_error(error_append(msg, reinterpret_cast<const char *>(gluErrorString(glGetError())))) {
41
42 }
43
44
45 GLCompileError::GLCompileError(const char *msg, const char *log)
46 : runtime_error(error_append(msg, reinterpret_cast<const char *>(gluErrorString(glGetError()))) + '\n' + log) {
47
48 }
49
50
51 SDLError::SDLError(const char *msg)
52 : runtime_error(error_append(msg, sdl_error_flush())) {
53
54 }
55
56 }