From 6874ef2452adc1a21ad52a8711089adb11bec9ae Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Mon, 5 Oct 2020 22:24:47 +0200 Subject: [PATCH] If a response doesn't have a content-type header, throw UnknownFormatException instead of ParseException --- .../java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt | 2 +- .../main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt b/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt index 017fd9fa..a03f6032 100644 --- a/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt +++ b/api/src/androidTest/java/com/readrops/api/localfeed/LocalRSSDataSourceTest.kt @@ -140,7 +140,7 @@ class LocalRSSDataSourceTest { localRSSDataSource.queryRSSResource(url.toString(), null) } - @Test(expected = ParseException::class) + @Test(expected = UnknownFormatException::class) fun noContentTypeTest() { mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_OK)) diff --git a/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt b/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt index 20a38da9..6069b2b0 100644 --- a/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt +++ b/api/src/main/java/com/readrops/api/localfeed/LocalRSSDataSource.kt @@ -37,7 +37,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) { return when { response.isSuccessful -> { val header = response.header(LibUtils.CONTENT_TYPE_HEADER) - ?: throw ParseException("Unable to get $url content-type") + ?: throw UnknownFormatException("Unable to get $url content-type") val contentType = LibUtils.parseContentType(header) ?: throw ParseException("Unable to parse $url content-type")