2019-04-16 11:40:38 +02:00
|
|
|
// Copyright © 2005, Ondra Kamenik
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
// $Id: exception.h 1367 2007-07-11 14:21:57Z kamenik $
|
|
|
|
|
|
|
|
#ifndef OGU_EXCEPTION_H
|
|
|
|
#define OGU_EXCEPTION_H
|
|
|
|
|
|
|
|
#include <string>
|
2019-01-10 18:24:04 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <utility>
|
2009-09-08 15:55:19 +02:00
|
|
|
|
2017-05-16 16:30:27 +02:00
|
|
|
namespace ogu
|
|
|
|
{
|
|
|
|
/** A primitive exception. */
|
|
|
|
class Exception
|
|
|
|
{
|
|
|
|
protected:
|
2019-01-10 18:24:04 +01:00
|
|
|
const std::string file;
|
|
|
|
const int line;
|
|
|
|
const std::string mes;
|
2017-05-16 16:30:27 +02:00
|
|
|
public:
|
2019-01-10 18:24:04 +01:00
|
|
|
Exception(std::string file_arg, int line_arg, std::string mes_arg)
|
|
|
|
: file{std::move(file_arg)},
|
|
|
|
line{line_arg},
|
|
|
|
mes{std::move(mes_arg)}
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
|
|
|
}
|
2019-01-10 18:24:04 +01:00
|
|
|
virtual ~Exception() = default;
|
|
|
|
|
2017-05-16 16:30:27 +02:00
|
|
|
void
|
2019-01-10 18:24:04 +01:00
|
|
|
print(std::ostream &out) const
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2019-01-10 18:24:04 +01:00
|
|
|
out << file << ':' << line << ": " << mes << std::endl;
|
2017-05-16 16:30:27 +02:00
|
|
|
}
|
2019-01-10 18:24:04 +01:00
|
|
|
|
2017-05-16 16:30:27 +02:00
|
|
|
void
|
|
|
|
print() const
|
|
|
|
{
|
2019-01-10 18:24:04 +01:00
|
|
|
print(std::cout);
|
2017-05-16 16:30:27 +02:00
|
|
|
}
|
2019-01-10 18:24:04 +01:00
|
|
|
|
|
|
|
std::string
|
2017-05-16 16:30:27 +02:00
|
|
|
message() const
|
|
|
|
{
|
|
|
|
return mes;
|
|
|
|
}
|
|
|
|
};
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|