The Battle for Wesnoth  1.15.1+dev
exception.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://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 <SDL2/SDL_error.h>
18 
19 namespace sdl
20 {
21 
22 static std::string create_error(const std::string& operation,
23  const bool use_sdl_error)
24 {
25  if(use_sdl_error) {
26  return operation + " Error »" + SDL_GetError() + "«.\n";
27  } else {
28  return operation;
29  }
30 }
31 
32 exception::exception(const std::string& operation, const bool use_sdl_error)
33  : game::error(create_error(operation, use_sdl_error))
34 {
35 }
36 
37 
38 } // namespace sdl
static l_noret error(LoadState *S, const char *why)
Definition: lundump.cpp:39
exception(const std::string &operation, const bool use_sdl_error)
Constructor.
Definition: exception.cpp:32
static std::string create_error(const std::string &operation, const bool use_sdl_error)
Definition: exception.cpp:22
Contains a basic exception class for SDL operations.