Add PTC server down logging
Add PTC server down logging
diff --git a/PokemonGo/RocketAPI/Console/Program.cs b/PokemonGo/RocketAPI/Console/Program.cs
index 95b2bcd..a15a1e2 100644
--- a/PokemonGo/RocketAPI/Console/Program.cs
+++ b/PokemonGo/RocketAPI/Console/Program.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using AllEnum;
using Google.Protobuf;
using PokemonGo.RocketAPI.Enums;
+using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.GeneratedCode;
using PokemonGo.RocketAPI.Helpers;
@@ -21,7 +22,21 @@ namespace PokemonGo.RocketAPI.Console
static void Main(string[] args)
{
- Task.Run(() => Execute());
+ Task.Run(() =>
+ {
+ try
+ {
+ Execute();
+ }
+ catch (PtcOfflineException)
+ {
+ System.Console.WriteLine("PTC Servers are probably down OR your credentials are wrong. Try google");
+ }
+ catch (Exception ex)
+ {
+ System.Console.WriteLine($"Unhandled exception: {ex}");
+ }
+ });
System.Console.ReadLine();
}
diff --git a/PokemonGo/RocketAPI/Exceptions/PTCOfflineException.cs b/PokemonGo/RocketAPI/Exceptions/PTCOfflineException.cs
new file mode 100644
index 0000000..86e088d
--- /dev/null
+++ b/PokemonGo/RocketAPI/Exceptions/PTCOfflineException.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PokemonGo.RocketAPI.Exceptions
+{
+ public class PtcOfflineException : Exception
+ {
+ }
+}
diff --git a/PokemonGo/RocketAPI/Login/PtcLogin.cs b/PokemonGo/RocketAPI/Login/PtcLogin.cs
index c05bcc7..f34f7bb 100644
--- a/PokemonGo/RocketAPI/Login/PtcLogin.cs
+++ b/PokemonGo/RocketAPI/Login/PtcLogin.cs
@@ -6,6 +6,7 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
+using PokemonGo.RocketAPI.Exceptions;
using PokemonGo.RocketAPI.Helpers;
namespace PokemonGo.RocketAPI.Login
@@ -41,6 +42,8 @@ namespace PokemonGo.RocketAPI.Login
}));
var ticketId = HttpUtility.ParseQueryString(loginResp.Headers.Location.Query)["ticket"];
+ if (ticketId == null)
+ throw new PtcOfflineException();
//Get tokenvar
var tokenResp = await tempHttpClient.PostAsync(Resources.PtcLoginOauth,
diff --git a/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj b/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
index 95b3426..993e66c 100644
--- a/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
+++ b/PokemonGo/RocketAPI/PokemonGo.RocketAPI.csproj
@@ -78,6 +78,7 @@
<Compile Include="Enums\AuthType.cs" />
<Compile Include="Enums\MiscEnums.cs" />
<Compile Include="Enums\RequestType.cs" />
+ <Compile Include="Exceptions\PtcOfflineException.cs" />
<Compile Include="Extensions\DateTimeExtensions.cs" />
<Compile Include="GeneratedCode\AllEnum.cs" />
<Compile Include="GeneratedCode\Payloads.cs" />
You may download the files in Public Git.