]> git.tdb.fi Git - libs/net.git/commitdiff
Provide more information about exceptions in Http::Server
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 Sep 2019 14:53:29 +0000 (17:53 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 Sep 2019 14:53:29 +0000 (17:53 +0300)
source/http/server.cpp

index f0474fd18e993c57de16b1a3f51c07dc260f069f..7caa0f5d025b6eb0e55db15f55cbf896aadf40ba 100644 (file)
@@ -1,6 +1,8 @@
 #include <exception>
+#include <typeinfo>
 #include <msp/core/maputils.h>
 #include <msp/core/refptr.h>
+#include <msp/debug/demangle.h>
 #include <msp/net/inet.h>
 #include <msp/net/resolve.h>
 #include <msp/net/streamsocket.h>
@@ -123,7 +125,8 @@ void Server::client_data_available(Client &cl)
                        catch(const exception &e)
                        {
                                response = new Response(BAD_REQUEST);
-                               response->add_content(e.what());
+                               response->add_content(format("An error occurred while parsing request headers:\ntype: %s\nwhat: %s",
+                                       Debug::demangle(typeid(e).name()), e.what()));
                        }
                        cl.in_buf = string();
                }
@@ -164,7 +167,8 @@ void Server::client_data_available(Client &cl)
                        responses.erase(cl.response);
                        cl.response = 0;
                        response = new Response(INTERNAL_ERROR);
-                       response->add_content(e.what());
+                       response->add_content(format("An error occurred while processing the request:\ntype: %s\nwhat: %s",
+                               Debug::demangle(typeid(e).name()), e.what()));
                }
        }