diff --git a/rend2d/servers/sdl_driver.cpp b/rend2d/servers/sdl_driver.cpp index cc102e661..89c1c79c2 100644 --- a/rend2d/servers/sdl_driver.cpp +++ b/rend2d/servers/sdl_driver.cpp @@ -2,7 +2,7 @@ #include #include -#include "../../tools/str_exception.hpp" +#include #include using namespace Mangle::Rend2D; @@ -70,7 +70,7 @@ int SDL_Sprite::height() { return surface->h; } SDLDriver::SDLDriver() : display(NULL), realDisp(NULL), softDouble(false) { if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1) - throw str_exception("Error initializing SDL video"); + throw std::runtime_error("Error initializing SDL video"); } SDLDriver::~SDLDriver() { @@ -94,7 +94,7 @@ void SDLDriver::setVideoMode(int width, int height, int bpp, bool fullscreen) // Create the surface and check it realDisp = SDL_SetVideoMode(width, height, bpp, flags); if(realDisp == NULL) - throw str_exception("Failed setting SDL video mode"); + throw std::runtime_error("Failed setting SDL video mode"); // Code for software double buffering. I haven't found this to be // any speed advantage at all in windowed mode (it's slower, as one @@ -160,7 +160,7 @@ Sprite* SDLDriver::loadImage(const std::string &file) SDL_Surface *surf = IMG_Load(file.c_str()); surf = convertImage(surf); if(surf == NULL) - throw str_exception("SDL failed to load image file '" + file + "'"); + throw std::runtime_error("SDL failed to load image file '" + file + "'"); return spriteFromSDL(surf); } @@ -171,7 +171,7 @@ Sprite* SDLDriver::loadImage(SDL_RWops *src, bool autoFree) SDL_Surface *surf = IMG_Load_RW(src, autoFree); surf = convertImage(surf); if(surf == NULL) - throw str_exception("SDL failed to load image"); + throw std::runtime_error("SDL failed to load image"); return spriteFromSDL(surf); } diff --git a/sound/filters/source_splicer.hpp b/sound/filters/source_splicer.hpp index 9fd49d126..9c7623086 100644 --- a/sound/filters/source_splicer.hpp +++ b/sound/filters/source_splicer.hpp @@ -2,7 +2,7 @@ #define MANGLE_SOUND_SOURCE_SPLICE_H #include "../source.hpp" -#include "../../tools/str_exception.hpp" +#include #include #include #include @@ -79,7 +79,7 @@ namespace Mangle if(catchAll) return catchAll->load(file); - throw str_exception("No handler for sound file " + file); + throw std::runtime_error("No handler for sound file " + file); } SampleSourcePtr load(Stream::StreamPtr input) { assert(0); } diff --git a/sound/outputs/openal_out.cpp b/sound/outputs/openal_out.cpp index 666dbe255..dd2da29b3 100644 --- a/sound/outputs/openal_out.cpp +++ b/sound/outputs/openal_out.cpp @@ -1,8 +1,8 @@ #include "openal_out.hpp" #include +#include #include "../../stream/filters/buffer_stream.hpp" -#include "../../tools/str_exception.hpp" #include "al.h" #include "alc.h" @@ -26,7 +26,7 @@ static char tmp_buffer[BSIZE]; const int STREAM_BUF_NUM = 4; static void fail(const std::string &msg) -{ throw str_exception("OpenAL exception: " + msg); } +{ throw std::runtime_error("OpenAL exception: " + msg); } /* Check for AL error. Since we're always calling this with string diff --git a/sound/sources/audiere_source.cpp b/sound/sources/audiere_source.cpp index 1f11272b0..9b97165be 100644 --- a/sound/sources/audiere_source.cpp +++ b/sound/sources/audiere_source.cpp @@ -1,12 +1,13 @@ #include "audiere_source.hpp" #include "../../stream/clients/audiere_file.hpp" -#include "../../tools/str_exception.hpp" + +#include using namespace Mangle::Stream; static void fail(const std::string &msg) -{ throw str_exception("Audiere exception: " + msg); } +{ throw std::runtime_error("Audiere exception: " + msg); } using namespace audiere; using namespace Mangle::Sound; diff --git a/sound/sources/ffmpeg_source.cpp b/sound/sources/ffmpeg_source.cpp index 2633515d8..fdc2ff954 100644 --- a/sound/sources/ffmpeg_source.cpp +++ b/sound/sources/ffmpeg_source.cpp @@ -1,6 +1,6 @@ #include "ffmpeg_source.hpp" -#include "../../tools/str_exception.hpp" +#include using namespace Mangle::Sound; @@ -9,7 +9,7 @@ using namespace Mangle::Sound; static uint8_t outBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE]; static void fail(const std::string &msg) -{ throw str_exception("FFMpeg exception: " + msg); } +{ throw std::runtime_error("FFMpeg exception: " + msg); } // --- Loader --- diff --git a/sound/sources/libsndfile.cpp b/sound/sources/libsndfile.cpp index 9ac7ee465..b69a2d436 100644 --- a/sound/sources/libsndfile.cpp +++ b/sound/sources/libsndfile.cpp @@ -1,12 +1,12 @@ #include "libsndfile.hpp" -#include "../../tools/str_exception.hpp" +#include #include using namespace Mangle::Stream; static void fail(const std::string &msg) -{ throw str_exception("Mangle::libsndfile: " + msg); } +{ throw std::runtime_error("Mangle::libsndfile: " + msg); } using namespace Mangle::Sound; diff --git a/sound/sources/mpg123_source.cpp b/sound/sources/mpg123_source.cpp index b0eeb77bb..24d6ecce1 100644 --- a/sound/sources/mpg123_source.cpp +++ b/sound/sources/mpg123_source.cpp @@ -1,6 +1,6 @@ #include "mpg123_source.hpp" -#include "../../tools/str_exception.hpp" +#include #include @@ -28,7 +28,7 @@ using namespace Mangle::Stream; */ static void fail(const std::string &msg) -{ throw str_exception("Mangle::Mpg123 exception: " + msg); } +{ throw std::runtime_error("Mangle::Mpg123 exception: " + msg); } static void checkError(int err, void *mh = NULL) { diff --git a/sound/sources/wav_source.cpp b/sound/sources/wav_source.cpp index 8e3e8558c..a46b3d27e 100644 --- a/sound/sources/wav_source.cpp +++ b/sound/sources/wav_source.cpp @@ -1,13 +1,14 @@ #include "wav_source.hpp" -#include "../../tools/str_exception.hpp" #include "../../stream/servers/file_stream.hpp" +#include + using namespace Mangle::Stream; using namespace Mangle::Sound; static void fail(const std::string &msg) -{ throw str_exception("Mangle::Wav exception: " + msg); } +{ throw std::runtime_error("Mangle::Wav exception: " + msg); } void WavSource::getInfo(int32_t *pRate, int32_t *pChannels, int32_t *pBits) { diff --git a/stream/servers/file_stream.hpp b/stream/servers/file_stream.hpp index c789d2022..314a49642 100644 --- a/stream/servers/file_stream.hpp +++ b/stream/servers/file_stream.hpp @@ -3,6 +3,7 @@ #include "std_stream.hpp" #include +#include namespace Mangle { namespace Stream { @@ -20,7 +21,7 @@ class FileStream : public StdStream file.open(name.c_str(), std::ios::binary); if(file.fail()) - throw str_exception("FileStream: failed to open file " + name); + throw std::runtime_error("FileStream: failed to open file " + name); } ~FileStream() { file.close(); } }; diff --git a/stream/servers/outfile_stream.hpp b/stream/servers/outfile_stream.hpp index 2946ff853..8d953d904 100644 --- a/stream/servers/outfile_stream.hpp +++ b/stream/servers/outfile_stream.hpp @@ -30,7 +30,7 @@ class OutFileStream : public StdOStream file.open(name.c_str(), mode); if(file.fail()) - throw str_exception("OutFileStream: failed to open file " + name); + throw std::runtime_error("OutFileStream: failed to open file " + name); } ~OutFileStream() { file.close(); } }; diff --git a/stream/servers/std_ostream.hpp b/stream/servers/std_ostream.hpp index f655477ff..797622631 100644 --- a/stream/servers/std_ostream.hpp +++ b/stream/servers/std_ostream.hpp @@ -3,7 +3,7 @@ #include "../stream.hpp" #include -#include "../../tools/str_exception.hpp" +#include namespace Mangle { namespace Stream { @@ -15,7 +15,7 @@ class StdOStream : public Stream std::ostream *inf; static void fail(const std::string &msg) - { throw str_exception("StdOStream: " + msg); } + { throw std::runtime_error("StdOStream: " + msg); } public: StdOStream(std::ostream *_inf) diff --git a/stream/servers/std_stream.hpp b/stream/servers/std_stream.hpp index 971c95415..68aca621b 100644 --- a/stream/servers/std_stream.hpp +++ b/stream/servers/std_stream.hpp @@ -3,7 +3,7 @@ #include "../stream.hpp" #include -#include "../../tools/str_exception.hpp" +#include namespace Mangle { namespace Stream { @@ -15,7 +15,7 @@ class StdStream : public Stream std::istream *inf; static void fail(const std::string &msg) - { throw str_exception("StdStream: " + msg); } + { throw std::runtime_error("StdStream: " + msg); } public: StdStream(std::istream *_inf) diff --git a/tools/str_exception.hpp b/tools/str_exception.hpp deleted file mode 100644 index 269501055..000000000 --- a/tools/str_exception.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __STR_EXCEPTION_H -#define __STR_EXCEPTION_H - -#include -#include - -/** @brief A simple exception that takes and holds a string - - Usage: - - throw str_exception("message"); - - */ -class str_exception : public std::exception -{ - std::string msg; - - public: - - str_exception(const std::string &m) : msg(m) {} - ~str_exception() throw() {} - const char* what() const throw() { return msg.c_str(); } -}; - -#endif