void BaseApp::notify( const Wt::WEvent & event )
{
static std::vector<std::string> exceptions =
{
"session was killed",
"all threads are busy"
};
static std::vector<std::string> pop_exceptions =
{
"basic_string::at: __n",
"bad lexical cast"
};
try
{
Wt::WApplication::notify(event);
}
catch( std::exception & exception )
{
for( auto except : exceptions )
if( std::string(exception.what()).find(except) != std::string::npos )
{
COUT_( "redirecting to: " + originalUrl( internalPath() ) );
redirect( originalUrl( internalPath() ) );
quit();
return;
}
auto message =
Wt::WString("EXCEPTION: '{1}'")
.arg( exception.what() )
.toUTF8()
;
txtLog( message, true );
for( auto except : pop_exceptions )
if( std::string(exception.what()).find(except) != std::string::npos )
{
Wt::WMessageBox::show
(
"Exception",
"<center>"
" Oh oh, something went wrong,<br />"
" please check what you are editing "
" and try again"
"</center>"
, Wt::Ok
);
return;
}
COUT_( "\n\n\n\n\n\n<<<<< EXCEPTION >>>>>>>" );
COUT_( exception.what() );
auto result =
system
(
emailText
(
"exception",
message,
{"adminemail@somesuchthing.com"}
).c_str()
);
(void)result;
COUT_( "redirecting to: " + originalUrl( internalPath() ) );
redirect( originalUrl( internalPath() ) );
quit();
}
}