2016-11-11 22:22:44 +00:00
|
|
|
// tasmet_exception.cpp
|
|
|
|
//
|
|
|
|
// last-edit-by: J.A. de Jong
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Implementation of exception TasMETBadAlloc
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "tasmet_exception.h"
|
2016-12-29 18:06:16 +00:00
|
|
|
#include <QString>
|
2016-11-11 22:22:44 +00:00
|
|
|
|
2016-12-22 09:32:39 +00:00
|
|
|
const char* TaSMETError::what() const throw() {
|
|
|
|
return _msg.c_str();
|
|
|
|
}
|
|
|
|
void TaSMETError::setContext(const std::string& ctx) {
|
|
|
|
std::string oldmsg = _msg;
|
|
|
|
_msg = ctx + ": " + oldmsg;
|
|
|
|
}
|
|
|
|
const char* TaSMETBadAlloc::what() const throw() {
|
2016-11-11 22:22:44 +00:00
|
|
|
return "Error: memory allocation failed. "
|
|
|
|
"Please make sure enough memory is available and restart the application";
|
|
|
|
}
|
2016-12-29 18:06:16 +00:00
|
|
|
void TaSMETError::show_user(const std::string& window_title,
|
|
|
|
QMessageBox::Icon icon) {
|
2016-11-11 22:22:44 +00:00
|
|
|
|
2016-12-29 18:06:16 +00:00
|
|
|
QString msg = what();
|
|
|
|
QMessageBox msgbx(icon,
|
|
|
|
QString::fromStdString(window_title),
|
|
|
|
msg);
|
|
|
|
|
|
|
|
msgbx.exec();
|
|
|
|
|
|
|
|
}
|
2016-11-11 22:22:44 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|