The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
exception.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "sdl/exception.hpp"
16 
17 #include <SDL_error.h>
18 #include "gpu.hpp"
19 
20 namespace sdl
21 {
22 
23 static std::string create_error(const std::string& operation,
24  const bool use_sdl_error)
25 {
26  if(use_sdl_error) {
27  return operation + " Error »" + SDL_GetError() + "«.\n";
28  } else {
29  return operation;
30  }
31 }
32 #ifdef SDL_GPU
33 static std::string create_gpu_error(const std::string &op,
34  const bool fetch_error_msg)
35 {
36  if (fetch_error_msg) {
37  return op + " Error »" + GPU_PopErrorCode().details + "«.\n";
38  } else {
39  return op;
40  }
41 }
42 #endif
43 
44 texception::texception(const std::string& operation, const bool use_sdl_error)
45  : game::error(create_error(operation, use_sdl_error))
46 {
47 }
48 
49 #ifdef SDL_GPU
50 tgpu_exception::tgpu_exception(const std::string &op,
51  const bool fetch_error_msg)
52  : game::error(create_gpu_error(op, fetch_error_msg))
53 {
54 }
55 #endif
56 
57 } // namespace sdl
static l_noret error(LoadState *S, const char *why)
Definition: lundump.cpp:29
char * details
Definition: SDL_gpu.h:461
GPU_ErrorObject GPU_PopErrorCode(void)
Definition: SDL_gpu.c:545
static std::string create_error(const std::string &operation, const bool use_sdl_error)
Definition: exception.cpp:23
Contains a basic exception class for SDL operations.
texception(const std::string &operation, const bool use_sdl_error)
Constructor.
Definition: exception.cpp:44
GLsizei const GLcharARB ** string
Definition: glew.h:4503