I am using (succesfully) Parse SDK for push notification, however I want to handle situation, when the subscribing to Parse server is unsucessfull (usually by bad internet connetion).
However it looks like Exception is threw inside Parse SDK, not handled and it ends up in default method private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
which is not what I want.
This is the code
try
{
this.Startup += async (sender, args) =>
{
try
{
// This optional line tracks statistics around app opens, including push effectiveness:
ParseAnalytics.TrackAppOpens(RootFrame);
// By convention, the empty string is considered a "Broadcast" channel
// Note that we had to add "async" to the definition to use the await keyword
await ParsePush.SubscribeAsync("");
}
catch (Exception ex)
{
Debug.WriteLine("jupiii");
}
};
}
catch (Exception ex)
{
Debug.WriteLine("jupiii");
}
I know that outer try-catch is meaningless, but I just tried it anyway to be sure, it is not handled there.
Without internet connection, the app crashes with exception
[Parse.ParseException] = {Parse.ParseException: Invalid response from server ---> System.ArgumentException: Input JSON was invalid.
at Parse.Internal.Json.Parse(String input)
at Parse.ParseClient.DeserializeJsonString(String jsonData)
at Parse.ParseClient.<>c__DisplayCl...
I thought that the problem could be in the async method, but I am awaiting it, which should be right thing to do, if I want catch exception.
Full stack trace
Parse.ParseException: Invalid response from server ---> System.ArgumentException: Input JSON was invalid.
at Parse.Internal.Json.Parse(String input)
at Parse.ParseClient.DeserializeJsonString(String jsonData)
at Parse.ParseClient.<>c__DisplayClassb.<RequestAsync>b__a(Task`1 t)
--- End of inner exception stack trace ---
at Parse.ParseClient.<>c__DisplayClassb.<RequestAsync>b__a(Task`1 t)
at Parse.Internal.InternalExtensions.<>c__DisplayClass1`2.<OnSuccess>b__0(Task t)
at Parse.Internal.InternalExtensions.<>c__DisplayClass7`1.<OnSuccess>b__6(Task t)
at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Parse.ParseAnalytics.<>c__DisplayClass3.<<TrackAppOpens>b__2>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)