view Exception/Exception.hpp @ 74:19d8825ec501

Add define for code that can never be reached. To avoid the line being counted.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Sat, 16 Feb 2013 15:26:27 +0100
parents c9447697609f
children
line wrap: on
line source

#ifndef EXCEPTION_HPP
#define EXCEPTION_HPP

#define NORETURN __attribute__ ((noreturn))
#define UNREACHABLE() abort()

#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