mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 22:07:28 +02:00
Initial version.
This commit is contained in:
parent
193aaa1a56
commit
b72c67a53e
228 changed files with 25924 additions and 0 deletions
42
TINKLib/Repository/Exception/WebExceptionHelper.cs
Normal file
42
TINKLib/Repository/Exception/WebExceptionHelper.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System.Net;
|
||||
|
||||
namespace TINK.Model.Repository.Exception
|
||||
{
|
||||
public static class WebExceptionHelper
|
||||
{
|
||||
/// <summary> Gets if a exception is caused by an error connecting to copri (LAN or mobile data off/ not reachable, proxy, ...).</summary>
|
||||
/// <param name="p_oException">Expection to check.</param>
|
||||
/// <returns>True if exception if caused by an connection error. </returns>
|
||||
public static bool GetIsConnectFailureException(this System.Exception p_oException)
|
||||
{
|
||||
var l_oException = p_oException as WebException;
|
||||
if (l_oException == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return l_oException.Status == WebExceptionStatus.ConnectFailure // Happens if WLAN and mobile data is off/ Router denies internet access/ ...
|
||||
|| l_oException.Status == WebExceptionStatus.NameResolutionFailure // Happens sometimes when not WLAN and no mobil connection are available (bad connection in lift).
|
||||
|| l_oException.Status == WebExceptionStatus.ReceiveFailure; // Happened when modile was connected to WLAN
|
||||
}
|
||||
|
||||
/// <summary> Gets if a exception is caused by clicking too fast.</summary>
|
||||
/// <param name="p_oException">Expection to check.</param>
|
||||
/// <returns>True if exception if caused by a fast click sequence. </returns>
|
||||
public static bool GetIsForbiddenException(this System.Exception p_oException)
|
||||
{
|
||||
if (!(p_oException is WebException l_oException))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(l_oException?.Response is HttpWebResponse l_oResponse))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return l_oException.Status == WebExceptionStatus.ProtocolError
|
||||
&& l_oResponse.StatusCode == HttpStatusCode.Forbidden;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue