Merge pull request #2753 from ByteHamster/parser-error-message
Better feed parser errors
This commit is contained in:
commit
4831e4d937
|
@ -317,7 +317,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
return handler.parseFeed(feed);
|
return handler.parseFeed(feed);
|
||||||
} catch (UnsupportedFeedtypeException e) {
|
} catch (UnsupportedFeedtypeException e) {
|
||||||
Log.d(TAG, "Unsupported feed type detected");
|
Log.d(TAG, "Unsupported feed type detected");
|
||||||
if (TextUtils.equals("html", e.getRootElement().toLowerCase())) {
|
if ("html".equalsIgnoreCase(e.getRootElement())) {
|
||||||
showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url());
|
showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url());
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -342,6 +342,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
|
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
|
||||||
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
|
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
|
||||||
showErrorDialog(errorMsg);
|
showErrorDialog(errorMsg);
|
||||||
|
Log.d(TAG, "Feed parser exception: " + Log.getStackTraceString(error));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,9 @@ public class TypeGetter {
|
||||||
Log.d(TAG, "Recognized type RSS 0.91/0.92");
|
Log.d(TAG, "Recognized type RSS 0.91/0.92");
|
||||||
return Type.RSS091;
|
return Type.RSS091;
|
||||||
}
|
}
|
||||||
|
throw new UnsupportedFeedtypeException("Unsupported rss version");
|
||||||
}
|
}
|
||||||
throw new UnsupportedFeedtypeException(Type.INVALID);
|
throw new UnsupportedFeedtypeException("No rss version attribute found");
|
||||||
default:
|
default:
|
||||||
Log.d(TAG, "Type is invalid");
|
Log.d(TAG, "Type is invalid");
|
||||||
throw new UnsupportedFeedtypeException(Type.INVALID, tag);
|
throw new UnsupportedFeedtypeException(Type.INVALID, tag);
|
||||||
|
|
|
@ -5,7 +5,8 @@ import de.danoeh.antennapod.core.syndication.handler.TypeGetter.Type;
|
||||||
public class UnsupportedFeedtypeException extends Exception {
|
public class UnsupportedFeedtypeException extends Exception {
|
||||||
private static final long serialVersionUID = 9105878964928170669L;
|
private static final long serialVersionUID = 9105878964928170669L;
|
||||||
private final TypeGetter.Type type;
|
private final TypeGetter.Type type;
|
||||||
private String rootElement;
|
private String rootElement;
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
public UnsupportedFeedtypeException(Type type) {
|
public UnsupportedFeedtypeException(Type type) {
|
||||||
super();
|
super();
|
||||||
|
@ -17,6 +18,11 @@ public class UnsupportedFeedtypeException extends Exception {
|
||||||
this.rootElement = rootElement;
|
this.rootElement = rootElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnsupportedFeedtypeException(String message) {
|
||||||
|
this.message = message;
|
||||||
|
type = Type.INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
public TypeGetter.Type getType() {
|
public TypeGetter.Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +33,9 @@ public class UnsupportedFeedtypeException extends Exception {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
if (type == TypeGetter.Type.INVALID) {
|
if (message != null) {
|
||||||
|
return message;
|
||||||
|
} else if (type == TypeGetter.Type.INVALID) {
|
||||||
return "Invalid type";
|
return "Invalid type";
|
||||||
} else {
|
} else {
|
||||||
return "Type " + type + " not supported";
|
return "Type " + type + " not supported";
|
||||||
|
|
Loading…
Reference in New Issue