GW2.NET
GW2.NET copied to clipboard
Transport Timeout Errors
[Moved from Codeplex: https://gw2dotnet.codeplex.com/workitem/1216]
When a timeout occurs, the default behavior is to throw a System.Net.WebException. Would it make sense to throw a System.TimeoutException instead? Timeouts are not as extreme as most other transport errors, and are usually caused by network congestion instead of a bad network configuration.
Ruhrpottpatriot wrote Aug 10, 2014 at 8:10 AM
I think it'd be best to throw a WebException with a TimeoutException being the inner exception
StevenLiekens wrote Aug 10, 2014 at 9:05 AM
We can't throw a new WebException and also preserve the original exception details that were generated by the framework. But we can catch the source WebException and wrap it in a new TimeoutException. So client code would look like this:
try { // Talk to the service service.GetBuild(); } catch (ServiceException ex) { // Handle errors generated by the server } catch (TimeoutException ex) { // Handle timeouts } catch (WebException ex) { // Handle fatal errors }