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.
Here's how it used to look:
if (DropboxServerException.class.isInstance(exception)) {
switch (((DropboxServerException) exception).error) {
case DropboxServerException._401_UNAUTHORIZED:
case DropboxServerException._403_FORBIDDEN:
case DropboxServerException._404_NOT_FOUND:
Log.w(TAG, "data has moved/disappeared, or something equally terminal.");
// do some error handling
break;
}
} 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?