<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [Java SDK v2] migration: error handling with HTTP codes in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Java-SDK-v2-migration-error-handling-with-HTTP-codes/m-p/216171#M11186</link>
    <description>&lt;P&gt;API v2 does offer much more granular errors, but you can use as much or as little of that granularity in your app as you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java#L61" target="_self"&gt;this example&lt;/A&gt; only does high level handling of any DbxException:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wheres &lt;A href="https://stackoverflow.com/documentation/dropbox-api/414/getting-a-shared-link-for-a-file-or-folder/2414/creating-a-shared-link-for-a-file-using-the-dropbox-java-library#t=201704141704219799122" target="_self"&gt;this example&lt;/A&gt;&amp;nbsp;distinguishes between &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.html" target="_self"&gt;CreateSharedLinkWithSettingsErrorException&lt;/A&gt; and &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxException.html" target="_self"&gt;DbxException&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can drill down into the subclasses to whatever extent you want for your app. For example, a &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/InvalidAccessTokenException.html" target="_self"&gt;InvalidAccessTokenException&lt;/A&gt;&amp;nbsp;indicates a bad access token, like a 401 in your v1 code.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2017 17:10:25 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2017-04-14T17:10:25Z</dc:date>
    <item>
      <title>[Java SDK v2] migration: error handling with HTTP codes</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Java-SDK-v2-migration-error-handling-with-HTTP-codes/m-p/216152#M11176</link>
      <description>&lt;P&gt;I'm migrating to the v2 Java SDK on Android, from the old Android SDK. I'm struggling to convert some error-handling code. This is a high-level error handler which could be handling an exception from any one of a number of Dropbox API methods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's how it used to look:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="row lines"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if&amp;nbsp;(DropboxServerException.class.isInstance(exception))&amp;nbsp;{&amp;nbsp;
    switch&amp;nbsp;(((DropboxServerException)&amp;nbsp;exception).error)&amp;nbsp;{&amp;nbsp;
&amp;nbsp; &amp;nbsp;     case&amp;nbsp;DropboxServerException._401_UNAUTHORIZED:&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;case&amp;nbsp;DropboxServerException._403_FORBIDDEN:&amp;nbsp;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case&amp;nbsp;DropboxServerException._404_NOT_FOUND:&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;     Log.w(TAG, "data&amp;nbsp;has&amp;nbsp;moved/disappeared,&amp;nbsp;or&amp;nbsp;something&amp;nbsp;equally&amp;nbsp;terminal.");&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // do some error handling
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&amp;nbsp;
    }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Now it looks as if I'm supposed to examine any one of dozens of different DbxApiException subclasses, and try to extract a meaningful error code from their messages. Please tell me there's a better way?&lt;/P&gt;&lt;DIV class="row lines"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="row lines"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="row lines"&gt;&lt;DIV class="old-line-no"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="new-line-no"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="row lines"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 May 2019 09:23:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Java-SDK-v2-migration-error-handling-with-HTTP-codes/m-p/216152#M11176</guid>
      <dc:creator>Graham B.</dc:creator>
      <dc:date>2019-05-29T09:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: [Java SDK v2] migration: error handling with HTTP codes</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Java-SDK-v2-migration-error-handling-with-HTTP-codes/m-p/216171#M11186</link>
      <description>&lt;P&gt;API v2 does offer much more granular errors, but you can use as much or as little of that granularity in your app as you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, &lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/account-info/src/main/java/com/dropbox/core/examples/account_info/Main.java#L61" target="_self"&gt;this example&lt;/A&gt; only does high level handling of any DbxException:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wheres &lt;A href="https://stackoverflow.com/documentation/dropbox-api/414/getting-a-shared-link-for-a-file-or-folder/2414/creating-a-shared-link-for-a-file-using-the-dropbox-java-library#t=201704141704219799122" target="_self"&gt;this example&lt;/A&gt;&amp;nbsp;distinguishes between &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/sharing/CreateSharedLinkWithSettingsErrorException.html" target="_self"&gt;CreateSharedLinkWithSettingsErrorException&lt;/A&gt; and &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/DbxException.html" target="_self"&gt;DbxException&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can drill down into the subclasses to whatever extent you want for your app. For example, a &lt;A href="https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/InvalidAccessTokenException.html" target="_self"&gt;InvalidAccessTokenException&lt;/A&gt;&amp;nbsp;indicates a bad access token, like a 401 in your v1 code.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 17:10:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Java-SDK-v2-migration-error-handling-with-HTTP-codes/m-p/216171#M11186</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-04-14T17:10:25Z</dc:date>
    </item>
  </channel>
</rss>

