-- | Stolen from rack: catches all exceptions raised from the app it wraps.moduleHack.Contrib.Middleware.ShowExceptions(show_exceptions)whereimportHackimportHack.Contrib.Middleware.HubimportMPSUTF8importPreludehiding((.),(^),(>),log)importData.MaybeimportData.DefaultimportSystem.IOimportSystem.IO.Errorprogram::Stringprogram="ShowExceptions"show_exceptions::Maybe(String->IO())->Middlewareshow_exceptionsstreamapp=\env->doletmy_stream=stream.fromMaybe(env.hack_errors)letlog=simple_loggermy_streamprogramappenv`catch`(handlerlog)wherehandler::Logger->IOError->IOResponsehandlerloge=doletmessage=e.showError.logmessagereturn$def{status=500,body=message}