The Battle for Wesnoth  1.19.4+dev
exception.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #include "sdl/exception.hpp"
17 
18 #include <SDL2/SDL_error.h>
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 
33 exception::exception(const std::string& operation, const bool use_sdl_error)
34  : game::error(create_error(operation, use_sdl_error))
35 {
36 }
37 
38 
39 } // namespace sdl
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.
exception(const std::string &operation, const bool use_sdl_error)
Constructor.
Definition: exception.cpp:33