title: WP8 - try-catch await method for Parse
body: <p>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).</p>
  
  <p>However it looks like Exception is threw inside Parse SDK, not handled and it ends up in default method <code>private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)</code> which is not what I want.</p>
  
  <p>This is the code</p>
  
  <pre><code>        try
          {
              this.Startup += async (sender, args) =&gt;
              {
                  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");
          }
  </code></pre>
  
  <p>I know that outer try-catch is meaningless, but I just tried it anyway to be sure, it is not handled there.</p>
  
  <p>Without internet connection, the app crashes with exception </p>
  
  <pre><code>[Parse.ParseException] = {Parse.ParseException: Invalid response from server ---&gt; System.ArgumentException: Input JSON was invalid.
     at Parse.Internal.Json.Parse(String input)
     at Parse.ParseClient.DeserializeJsonString(String jsonData)
     at Parse.ParseClient.&lt;&gt;c__DisplayCl...
  </code></pre>
  
  <p>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.</p>
  
  <hr>
  
  <p>Full stack trace</p>
  
  <pre><code>Parse.ParseException: Invalid response from server ---&gt; System.ArgumentException: Input JSON was invalid.
     at Parse.Internal.Json.Parse(String input)
     at Parse.ParseClient.DeserializeJsonString(String jsonData)
     at Parse.ParseClient.&lt;&gt;c__DisplayClassb.&lt;RequestAsync&gt;b__a(Task`1 t)
     --- End of inner exception stack trace ---
     at Parse.ParseClient.&lt;&gt;c__DisplayClassb.&lt;RequestAsync&gt;b__a(Task`1 t)
     at Parse.Internal.InternalExtensions.&lt;&gt;c__DisplayClass1`2.&lt;OnSuccess&gt;b__0(Task t)
     at Parse.Internal.InternalExtensions.&lt;&gt;c__DisplayClass7`1.&lt;OnSuccess&gt;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.&lt;&gt;c__DisplayClass3.&lt;&lt;TrackAppOpens&gt;b__2&gt;d__5.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&lt;ThrowAsync&gt;b__3(Object state)
  </code></pre>