Change to handle json parse exception instead of xml.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-01-07 13:20:59 +01:00
parent 27465a086d
commit ada94dc24f
2 changed files with 8 additions and 9 deletions

View File

@ -12,7 +12,7 @@ sourceSets {
dependencies {
api other.kotlinStdlib
api other.retrofit
implementation other.jacksonConverter
api other.jacksonConverter
implementation(other.jacksonKotlin) {
exclude module: 'kotlin-reflect'
}

View File

@ -22,11 +22,11 @@ import android.app.Activity;
import android.os.Handler;
import android.util.Log;
import org.moire.ultrasonic.R;
import com.fasterxml.jackson.core.JsonParseException;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.service.parser.SubsonicRESTException;
import org.moire.ultrasonic.subsonic.RestErrorMapper;
import org.xmlpull.v1.XmlPullParserException;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -82,16 +82,15 @@ public abstract class BackgroundTask<T> implements ProgressListener
return activity.getResources().getString(R.string.background_task_not_found);
}
if (error instanceof IOException)
if (error instanceof JsonParseException) {
return activity.getResources().getString(R.string.background_task_parse_error);
}
if (error instanceof IOException)
{
return activity.getResources().getString(R.string.background_task_network_error);
}
if (error instanceof XmlPullParserException)
{
return activity.getResources().getString(R.string.background_task_parse_error);
}
if (error instanceof SubsonicRESTException) {
return RestErrorMapper.getLocalizedErrorMessage((SubsonicRESTException) error, activity);
}