[SignalR-Client-Cpp] Cannot properly handle invalid url
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When use a url like "/something" then start the connection,
It seems that underline lib cpprest does not allow empty host and throw the exception, but the exception does not return in the callback, instead, it terminates the program.
```
terminate called after throwing an instance of 'std::invalid_argument'
what(): URI must contain a hostname.
Aborted
```
**and this cannot be catched in anyway because the function `hub_connection::start(std::function callback) noexcept;` is a `noexcept` function**
[https://docs.microsoft.com/en-us/cpp/cpp/noexcept-cpp?view=msvc-170](url)
> Mark a function as noexcept only if all the functions that it calls, either directly or indirectly, are also noexcept or const. The compiler doesn't necessarily check every code path for exceptions that might bubble up to a noexcept function. If an exception does exit the outer scope of a function marked noexcept, [std::terminate](https://docs.microsoft.com/en-us/cpp/standard-library/exception-functions?view=msvc-170#terminate) is invoked immediately, and there's no guarantee that destructors of any in-scope objects will be invoked.
### Expected Behavior
With the mark of noexcept in hub_connection::start() function, any exceptions that might occur are expected to be in the callback.
Otherwise, it should not be marked with noexcept and let user handle any exception that might come out from it.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.