view Exception/Exception.hpp @ 73:c9447697609f

Fixed some issues with raise. 100% function code coverage for Exceptions.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Thu, 31 Jan 2013 20:33:01 +0100
parents b2c2c2bf2bbd
children 19d8825ec501
line wrap: on
line source

#ifndef EXCEPTION_HPP
#define EXCEPTION_HPP

#define NORETURN __attribute__ ((noreturn))

#include <QtCore/QString>

class Exception {

public:
  typedef QString string_t;

  virtual const string_t& toString() const
  {
    return errorMsg_;
  }

  virtual void raise() const NORETURN = 0;

protected:
  Exception(const string_t& errorMsg = string_t()) : errorMsg_(errorMsg) {}
  virtual ~Exception() {}

  void setErrorMsg(string_t& errorMsg);
  const string_t& errorMsg(string_t& errorMsg);

private:
  string_t errorMsg_;
};

#endif //EXCEPTION_HPP