microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.97k stars 1.65k forks source link

Different exceptions thrown on linux and windows #1612

Open VojtechFried opened 3 years ago

VojtechFried commented 3 years ago

When I start http_listener (see code below) with an already bound port, on windows it throws http_exception, but on linux it throws some boost exception. Also if I start two servers with the same URI, std::bad_argument is thrown on linux (http_exception on windows). So there is some platform inconsistency or maybe a difference when using asio vs. windows http server. It should throw in these cases http_exception.

uri_builder uriBuilder(_XPLATSTR("http://localhost"));
uriBuilder.set_port(port);
auto listener = http_listener(uriBuilder.to_uri());
listener.open().get();
sebkraemer commented 3 years ago

IMO the cpprestsdk API should not expose the boost exception. I also agree that different types of exceptions are suboptimal regarding writing platform independet client code.