Commit 728083ab authored by Ilya Prokhorov's avatar Ilya Prokhorov

Throw exception from framework

parent 684c5804
......@@ -15,7 +15,7 @@ Music::Music(shared_ptr<string> path) {
if (music == nullptr) {
//cout << "Can't load music " << Mix_GetError() << endl;
throw runtime_error("Can't load music");
FSCUtils::throwRuntimeException(string("Can't load music"));
}
#else
......@@ -30,11 +30,11 @@ void Music::play() {
#ifndef __EMSCRIPTEN__
if (music) {
if (Mix_PlayMusic(music, -1) == -1) {
throw runtime_error("Can't play music");
FSCUtils::throwRuntimeException(string("Can't play music"));
}
}
else {
throw runtime_error("Can't play music - music is null");
FSCUtils::throwRuntimeException(string("Can't play music - music is null"));
}
#else
if (path.get() != nullptr) {
......
......@@ -2,6 +2,7 @@
#define FSBH_SOUND_SYSTEM_PLAYABLE_H
#include <stdexcept>
#include <FlameSteelCore/FSCUtils.h>
using namespace std;
......@@ -9,8 +10,8 @@ namespace FlameSteelBattleHorn {
class Playable {
public:
virtual void play() { throw logic_error("Call to not overriden method play, playable abstract class"); };
virtual void stop() { throw logic_error("Call to not overriden method stop, playable abstract class"); };
virtual void play() { FSCUtils::throwRuntimeException(string("Call to not overriden method play, playable abstract class")); };
virtual void stop() { FSCUtils::throwRuntimeException(string("Call to not overriden method stop, playable abstract class")); };
};
};
......
......@@ -12,7 +12,7 @@ void Sound::initializeSoundSystem() {
#ifndef __EMSCRIPTEN__
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1 ) {
throw runtime_error("Can't initialize sound system");
FSCUtils::throwRuntimeException(string("Can't initialize sound system"));
}
int flags = MIX_INIT_OGG;
......@@ -24,7 +24,7 @@ void Sound::initializeSoundSystem() {
if ((initted & flags) != flags) {
printf("Mix_Init: Failed to init required ogg and mod support!\n");
printf("Mix_Init: %s\n", Mix_GetError());
throw runtime_error("Can't initialize SDL_Mixer properly");
FSCUtils::throwRuntimeException(string("Can't initialize SDL_Mixer properly"));
}
else {
//cout << "SDL_MIXER initialized correctly" << endl;
......@@ -41,7 +41,7 @@ Sound::Sound(shared_ptr<string> path) {
if (chunk == nullptr) {
//cout << "Can't load sound " << Mix_GetError() << endl;
throw runtime_error("Can't load sound");
FSCUtils::throwRuntimeException(string("Can't load sound"));
}
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment