title: Casablanca webserver gives seemingly random error
body: <p>I am using the <a href="https://casablanca.codeplex.com/" rel="nofollow">Casablanca</a> REST SDK to make a webservice. The webservice has the client pass JSON through the URL and processes it. However in some cases if I send JSON that contains an array, it will crash the service. The strange part is the handler method that actually handles the JSON runs all the way through and ends before the error is given. My main function is:</p>
  
  <pre><code>int main()
  {   
      std::string ip;
      std::string port;
      std::ifstream inputStream;
      inputStream.open("ip_port.config");
      while(!inputStream.eof())
      {
          inputStream &gt;&gt; ip;
          inputStream &gt;&gt; port;
      }
      inputStream.close();
  
      std::string uri = "http://"+ip+":"+port+"/";
      //set up URL
      web::http::uri u(U(uri)); 
  
      //set up listener for URL
      web::http::experimental::listener::http_listener listener(u);
      listener.support(methods::GET, handle_get);
      try
          {
              pplx::task&lt;void&gt; l = listener.open();
              while(true)
              {
                  l.wait();
                  sleep(1);
              }
              listener.close().wait();
          }
      catch(int e)
      {
          std::stringstream errorMessage;
          errorMessage &lt;&lt; "Error: " &lt;&lt; e; 
          logRequest(errorMessage.str(), "Error Message");
      }
      return 0;
  }
  </code></pre>
  
  <p>I have put two prints: "Beginning of Handler" and "End of Handler" in the handle_get function, which are both printed, leading me to beleive that the cause of the error has something to do with the while loop with the listener, but the error it gives has nothing to do with the listener:</p>
  
  <pre><code>terminate called after throwing an instance of 'std::out_of_range'
     what():  basic_string::substr
  </code></pre>
  
  <p>Im trying to wrap my head around what about the listener could return that error.</p>