Commit 089ac36c authored by jan.koester's avatar jan.koester
Browse files

style error output

parent 3e387d97
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ namespace blogi {
                return false;
            }

            std::string path;
            std::string sid,path;

            if(req->getRequestURL()+strlen(Args->config->buildurl("nginxfiler",url,512)))
                path=req->getRequestURL()+strlen(Args->config->buildurl("nginxfiler",url,512));
@@ -161,6 +161,7 @@ namespace blogi {

            std::shared_ptr<netplus::tcp> srvsock;
            std::shared_ptr<netplus::tcp> cltsock;

            try{
                try{
                    srvsock=std::make_shared<netplus::tcp>(_NHost.c_str(),_NPort,2,0);
@@ -330,7 +331,6 @@ namespace blogi {
                }

                libhtmlpp::HtmlString fileHtml,out;
                std::string sid;

                try{
                    RenderUI(path,ndir,fileHtml);
@@ -355,10 +355,28 @@ namespace blogi {
                curres.send(req, out.c_str(),out.size());
            }catch(libhttppp::HTTPException &e){
                libhttppp::HttpResponse curres;
                libhtmlpp::HtmlString error,out;

                Args->theme->printSite(tid,out,page,req->getRequestURL(),Args->auth->isLoggedIn(tid,req,sid));

                error << "<div class=\"errormsg\" >" << e.what() << "</div>";

                libhtmlpp::HtmlElement *index=(libhtmlpp::HtmlElement*)out.parse(),*main=nullptr;

                if(index)
                    main=index->getElementbyID("main");

                if(!index || ! main){
                    curres.setVersion(HTTPVERSION(1.1));
                    curres.setContentType("text/html");
                    curres.setState(HTTP500);
                    curres.send(req, e.what(),strlen(e.what()));
                    return true;
                }

                main->appendChild(error.parse());

                curres.send(req, out.c_str(),out.size());
            }
            return true;
        }