Am 02.06.2017 um 00:01 schrieb Stefan:

On Tue, 30 May 2017 09:54:19 -0400, Steven Schveighoffer wrote:

Other exceptions will just print an exception to the web page and
continue running. With a web server, it's kind of expected that any
error in a web page will not bring down the whole thing. Is there a way
to specifically catch RangeError and continue to run?

Why don't you wrap the request handler into a try-catch block?

void foo(HTTPServerRequest req, HTTPServerResponse res)
{
   string[string] map = [
      "eins": "one"
   ];
   res.writeBody (map["9"]);
}

T wrap(T) (T f)
{
   return (HTTPServerRequest i, HTTPServerResponse j) {
      try
         f (i, j);
      catch (Throwable) {
         import std.stdio;
         stderr.writeln ("caught something");
      }
   };
}
...
   router.get("/test", toDelegate (&foo).wrap);
...

Definitely a possibility as long as it is absolutely certain that no
RAII is going on within the try block and as long as the compiler still
supports catching Errors.