Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion oxygine/src/oxygine/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ namespace oxygine
class Event
{
public:
enum { COMPLETE = sysEventID('C', 'M', 'P') };
enum {
COMPLETE = sysEventID('C', 'M', 'P'),
ERROR = sysEventID('E', 'R', 'R')
};

enum Phase
{
Expand Down
8 changes: 7 additions & 1 deletion oxygine/src/oxygine/EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ namespace oxygine
listenerbase& ls = copy[i];
event->currentTarget = this;
event->listenerID = ls.id;
ls.cb(event);
try{
ls.cb(event);
} catch (const oxygine::event_exception &ex) {
Event e(Event::ERROR);
e.userData = (void*) &ex;
dispatchEvent(&e);
}
if (event->stopsImmediatePropagation)
break;
}
Expand Down
5 changes: 5 additions & 0 deletions oxygine/src/oxygine/EventDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace oxygine
#define EventID(str) EventIDc11(str)


class event_exception : public std::runtime_error {
public:
event_exception(const char* what) : std::runtime_error(what) { }
event_exception(const event_exception &other) : event_exception(other.what()) { }
};
DECLARE_SMART(EventDispatcher, spEventDispatcher);
class EventDispatcher: public Object
{
Expand Down