Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/onlinejob.h
Context not available. | |||||
20 | #ifndef ONLINEJOB_H | 20 | #ifndef ONLINEJOB_H | ||
---|---|---|---|---|---|
21 | #define ONLINEJOB_H | 21 | #define ONLINEJOB_H | ||
22 | 22 | | |||
23 | #define STRINGIFY(x) #x | ||||
24 | #define TOSTRING(x) STRINGIFY(x) | ||||
25 | #define BADTASKEXCEPTION(what) badTaskCast("Casted onlineTask with wrong type. " __FILE__ ":" TOSTRING(__LINE__)) | ||||
26 | #define EMPTYTASKEXCEPTION(what) emptyTask("Requested onlineTask of onlineJob without any task. " __FILE__ ":" TOSTRING(__LINE__)) | ||||
27 | | ||||
23 | #include <QMetaType> | 28 | #include <QMetaType> | ||
24 | #include <QString> | 29 | #include <QString> | ||
25 | #include "mymoneyobject.h" | 30 | #include "mymoneyobject.h" | ||
Context not available. | |||||
288 | * | 293 | * | ||
289 | * This is inspired by std::bad_cast | 294 | * This is inspired by std::bad_cast | ||
290 | */ | 295 | */ | ||
291 | class badTaskCast : public MyMoneyException | 296 | class badTaskCast : public std::runtime_error | ||
292 | { | 297 | { | ||
293 | public: | 298 | public: | ||
294 | explicit badTaskCast(const QString& file = QString(), const long unsigned int& line = 0) | 299 | explicit badTaskCast(const char *msg) : std::runtime_error(msg) {} | ||
295 | : MyMoneyException("Casted onlineTask with wrong type", file, line) {} | | |||
296 | }; | 300 | }; | ||
297 | 301 | | |||
298 | /** | 302 | /** | ||
299 | * @brief Thrown if a task of an invalid onlineJob is requested | 303 | * @brief Thrown if a task of an invalid onlineJob is requested | ||
300 | */ | 304 | */ | ||
301 | class emptyTask : public MyMoneyException | 305 | class emptyTask : public std::runtime_error | ||
302 | { | 306 | { | ||
303 | public: | 307 | public: | ||
304 | explicit emptyTask(const QString& file = QString(), const long unsigned int& line = 0) | 308 | explicit emptyTask(const char *msg) : std::runtime_error(msg) {} | ||
305 | : MyMoneyException("Requested onlineTask of onlineJob without any task", file, line) {} | | |||
306 | }; | 309 | }; | ||
307 | 310 | | |||
308 | /** @brief onlineTask attatched to this job */ | 311 | /** @brief onlineTask attatched to this job */ | ||
Context not available. | |||||
337 | { | 340 | { | ||
338 | T* ret = dynamic_cast<T*>(m_task); | 341 | T* ret = dynamic_cast<T*>(m_task); | ||
339 | if (ret == 0) | 342 | if (ret == 0) | ||
340 | throw badTaskCast(__FILE__, __LINE__); | 343 | throw EMPTYTASKEXCEPTION(); | ||
344 | // throw badTaskCast(__FILE__, __LINE__); | ||||
341 | return ret; | 345 | return ret; | ||
342 | } | 346 | } | ||
343 | 347 | | |||
Context not available. | |||||
346 | { | 350 | { | ||
347 | const T* ret = dynamic_cast<const T*>(m_task); | 351 | const T* ret = dynamic_cast<const T*>(m_task); | ||
348 | if (ret == 0) | 352 | if (ret == 0) | ||
349 | throw badTaskCast(__FILE__, __LINE__); | 353 | throw BADTASKEXCEPTION(); | ||
354 | // throw badTaskCast(__FILE__, __LINE__); | ||||
350 | return ret; | 355 | return ret; | ||
351 | } | 356 | } | ||
352 | 357 | | |||
Context not available. |