Commit 6b2bc71b authored by Ilya Prokhorov's avatar Ilya Prokhorov

Throw exception from framework

parent bf4f1c4d
......@@ -9,12 +9,20 @@
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
FSCUtils::FSCUtils() {
// TODO Auto-generated constructor stub
}
void FSCUtils::throwRuntimeException(string error) {
cout << error << endl;
throw runtime_error(error);
};
int FSCUtils::FSCRandomInt(int maximalInt) {
if (maximalInt == 0) {
......
......@@ -26,6 +26,8 @@ public:
static shared_ptr<string> localizedString(shared_ptr<string> key);
static void throwRuntimeException(string error);
virtual ~FSCUtils();
};
......
......@@ -9,6 +9,7 @@
#include <iostream>
#include "Objects.h"
#include <FlameSteelCore/FSCUtils.h>
using namespace std;
......@@ -58,14 +59,14 @@ shared_ptr<Object> Object::getComponent(shared_ptr<string> identifier) {
string errorString = "Object::getComponent - there is no component with class identifier: ";
errorString += *identifier.get();
throw logic_error(errorString);
FSCUtils::throwRuntimeException(errorString);
}
else if (objects.size() > 1)
{
string errorString = "Object::getComponent - trying to get component from many components with same class identifier: ";
errorString += *identifier.get();
throw logic_error(errorString);
FSCUtils::throwRuntimeException(errorString);
}
auto object = objects[0];
......
......@@ -9,6 +9,7 @@
#include <cstddef>
#include <iostream>
#include <FlameSteelCore/FSCUtils.h>
Objects::Objects() {
......@@ -36,7 +37,7 @@ void Objects::addObject(shared_ptr<Object> object) {
if (object->getClassIdentifier().get() == nullptr) {
throw logic_error("Trying to add object with classIdentifier = nullptr");
FSCUtils::throwRuntimeException(string("Trying to add object with classIdentifier = nullptr"));
}
......@@ -45,7 +46,7 @@ void Objects::addObject(shared_ptr<Object> object) {
string errorString = "Trying to add object with instanceIdentifier = nullptr; With class identifier: ";
errorString += *object->getClassIdentifier().get();
throw logic_error(errorString);
FSCUtils::throwRuntimeException(errorString);
}
......@@ -85,7 +86,7 @@ void Objects::removeObject(shared_ptr<Object> object) {
if (object.get() == nullptr)
{
throw logic_error("Trying to remove nullptr object");
FSCUtils::throwRuntimeException(string("Trying to remove nullptr object"));
}
auto index = 0;
......
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