Skip to content

Commit 053074b

Browse files
committed
Killed str_error, std::runtime_error does the job
1 parent 2407f21 commit 053074b

13 files changed

+28
-50
lines changed

rend2d/servers/sdl_driver.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <SDL.h>
44
#include <SDL_image.h>
5-
#include "../../tools/str_exception.hpp"
5+
#include <stdexcept>
66
#include <assert.h>
77

88
using namespace Mangle::Rend2D;
@@ -70,7 +70,7 @@ int SDL_Sprite::height() { return surface->h; }
7070
SDLDriver::SDLDriver() : display(NULL), realDisp(NULL), softDouble(false)
7171
{
7272
if (SDL_InitSubSystem( SDL_INIT_VIDEO ) == -1)
73-
throw str_exception("Error initializing SDL video");
73+
throw std::runtime_error("Error initializing SDL video");
7474
}
7575
SDLDriver::~SDLDriver()
7676
{
@@ -94,7 +94,7 @@ void SDLDriver::setVideoMode(int width, int height, int bpp, bool fullscreen)
9494
// Create the surface and check it
9595
realDisp = SDL_SetVideoMode(width, height, bpp, flags);
9696
if(realDisp == NULL)
97-
throw str_exception("Failed setting SDL video mode");
97+
throw std::runtime_error("Failed setting SDL video mode");
9898

9999
// Code for software double buffering. I haven't found this to be
100100
// any speed advantage at all in windowed mode (it's slower, as one
@@ -160,7 +160,7 @@ Sprite* SDLDriver::loadImage(const std::string &file)
160160
SDL_Surface *surf = IMG_Load(file.c_str());
161161
surf = convertImage(surf);
162162
if(surf == NULL)
163-
throw str_exception("SDL failed to load image file '" + file + "'");
163+
throw std::runtime_error("SDL failed to load image file '" + file + "'");
164164
return spriteFromSDL(surf);
165165
}
166166

@@ -171,7 +171,7 @@ Sprite* SDLDriver::loadImage(SDL_RWops *src, bool autoFree)
171171
SDL_Surface *surf = IMG_Load_RW(src, autoFree);
172172
surf = convertImage(surf);
173173
if(surf == NULL)
174-
throw str_exception("SDL failed to load image");
174+
throw std::runtime_error("SDL failed to load image");
175175
return spriteFromSDL(surf);
176176
}
177177

sound/filters/source_splicer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define MANGLE_SOUND_SOURCE_SPLICE_H
33

44
#include "../source.hpp"
5-
#include "../../tools/str_exception.hpp"
5+
#include <stdexcept>
66
#include <string>
77
#include <list>
88
#include <assert.h>
@@ -79,7 +79,7 @@ namespace Mangle
7979
if(catchAll)
8080
return catchAll->load(file);
8181

82-
throw str_exception("No handler for sound file " + file);
82+
throw std::runtime_error("No handler for sound file " + file);
8383
}
8484

8585
SampleSourcePtr load(Stream::StreamPtr input) { assert(0); }

sound/outputs/openal_out.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "openal_out.hpp"
22
#include <assert.h>
3+
#include <stdexcept>
34

45
#include "../../stream/filters/buffer_stream.hpp"
5-
#include "../../tools/str_exception.hpp"
66

77
#include "al.h"
88
#include "alc.h"
@@ -26,7 +26,7 @@ static char tmp_buffer[BSIZE];
2626
const int STREAM_BUF_NUM = 4;
2727

2828
static void fail(const std::string &msg)
29-
{ throw str_exception("OpenAL exception: " + msg); }
29+
{ throw std::runtime_error("OpenAL exception: " + msg); }
3030

3131
/*
3232
Check for AL error. Since we're always calling this with string

sound/sources/audiere_source.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "audiere_source.hpp"
22

33
#include "../../stream/clients/audiere_file.hpp"
4-
#include "../../tools/str_exception.hpp"
4+
5+
#include <stdexcept>
56

67
using namespace Mangle::Stream;
78

89
static void fail(const std::string &msg)
9-
{ throw str_exception("Audiere exception: " + msg); }
10+
{ throw std::runtime_error("Audiere exception: " + msg); }
1011

1112
using namespace audiere;
1213
using namespace Mangle::Sound;

sound/sources/ffmpeg_source.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "ffmpeg_source.hpp"
22

3-
#include "../../tools/str_exception.hpp"
3+
#include <stdexcept>
44

55
using namespace Mangle::Sound;
66

@@ -9,7 +9,7 @@ using namespace Mangle::Sound;
99
static uint8_t outBuf[AVCODEC_MAX_AUDIO_FRAME_SIZE];
1010

1111
static void fail(const std::string &msg)
12-
{ throw str_exception("FFMpeg exception: " + msg); }
12+
{ throw std::runtime_error("FFMpeg exception: " + msg); }
1313

1414
// --- Loader ---
1515

sound/sources/libsndfile.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "libsndfile.hpp"
22

3-
#include "../../tools/str_exception.hpp"
3+
#include <stdexcept>
44
#include <sndfile.h>
55

66
using namespace Mangle::Stream;
77

88
static void fail(const std::string &msg)
9-
{ throw str_exception("Mangle::libsndfile: " + msg); }
9+
{ throw std::runtime_error("Mangle::libsndfile: " + msg); }
1010

1111
using namespace Mangle::Sound;
1212

sound/sources/mpg123_source.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "mpg123_source.hpp"
22

3-
#include "../../tools/str_exception.hpp"
3+
#include <stdexcept>
44

55
#include <mpg123.h>
66

@@ -28,7 +28,7 @@ using namespace Mangle::Stream;
2828
*/
2929

3030
static void fail(const std::string &msg)
31-
{ throw str_exception("Mangle::Mpg123 exception: " + msg); }
31+
{ throw std::runtime_error("Mangle::Mpg123 exception: " + msg); }
3232

3333
static void checkError(int err, void *mh = NULL)
3434
{

sound/sources/wav_source.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#include "wav_source.hpp"
22

3-
#include "../../tools/str_exception.hpp"
43
#include "../../stream/servers/file_stream.hpp"
54

5+
#include <stdexcept>
6+
67
using namespace Mangle::Stream;
78
using namespace Mangle::Sound;
89

910
static void fail(const std::string &msg)
10-
{ throw str_exception("Mangle::Wav exception: " + msg); }
11+
{ throw std::runtime_error("Mangle::Wav exception: " + msg); }
1112

1213
void WavSource::getInfo(int32_t *pRate, int32_t *pChannels, int32_t *pBits)
1314
{

stream/servers/file_stream.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "std_stream.hpp"
55
#include <fstream>
6+
#include <stdexcept>
67

78
namespace Mangle {
89
namespace Stream {
@@ -20,7 +21,7 @@ class FileStream : public StdStream
2021
file.open(name.c_str(), std::ios::binary);
2122

2223
if(file.fail())
23-
throw str_exception("FileStream: failed to open file " + name);
24+
throw std::runtime_error("FileStream: failed to open file " + name);
2425
}
2526
~FileStream() { file.close(); }
2627
};

stream/servers/outfile_stream.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class OutFileStream : public StdOStream
3030
file.open(name.c_str(), mode);
3131

3232
if(file.fail())
33-
throw str_exception("OutFileStream: failed to open file " + name);
33+
throw std::runtime_error("OutFileStream: failed to open file " + name);
3434
}
3535
~OutFileStream() { file.close(); }
3636
};

stream/servers/std_ostream.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../stream.hpp"
55
#include <iostream>
6-
#include "../../tools/str_exception.hpp"
6+
#include <stdexcept>
77

88
namespace Mangle {
99
namespace Stream {
@@ -15,7 +15,7 @@ class StdOStream : public Stream
1515
std::ostream *inf;
1616

1717
static void fail(const std::string &msg)
18-
{ throw str_exception("StdOStream: " + msg); }
18+
{ throw std::runtime_error("StdOStream: " + msg); }
1919

2020
public:
2121
StdOStream(std::ostream *_inf)

stream/servers/std_stream.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "../stream.hpp"
55
#include <iostream>
6-
#include "../../tools/str_exception.hpp"
6+
#include <stdexcept>
77

88
namespace Mangle {
99
namespace Stream {
@@ -15,7 +15,7 @@ class StdStream : public Stream
1515
std::istream *inf;
1616

1717
static void fail(const std::string &msg)
18-
{ throw str_exception("StdStream: " + msg); }
18+
{ throw std::runtime_error("StdStream: " + msg); }
1919

2020
public:
2121
StdStream(std::istream *_inf)

tools/str_exception.hpp

-25
This file was deleted.

0 commit comments

Comments
 (0)