mirror of https://github.com/readrops/Readrops.git
Use HttpException in LocalRSSDataSource
This commit is contained in:
parent
35ad5dfbc4
commit
4697219312
|
@ -7,6 +7,7 @@ import com.gitlab.mvysny.konsumexml.konsumeXml
|
|||
import com.readrops.api.localfeed.json.JSONFeedAdapter
|
||||
import com.readrops.api.utils.ApiUtils
|
||||
import com.readrops.api.utils.AuthInterceptor
|
||||
import com.readrops.api.utils.exceptions.HttpException
|
||||
import com.readrops.api.utils.exceptions.ParseException
|
||||
import com.readrops.api.utils.exceptions.UnknownFormatException
|
||||
import com.readrops.db.entities.Feed
|
||||
|
@ -32,7 +33,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) : KoinComponent {
|
|||
* @param headers request headers
|
||||
* @return a Feed object with its items
|
||||
*/
|
||||
@Throws(ParseException::class, UnknownFormatException::class, NetworkErrorException::class, IOException::class)
|
||||
@Throws(ParseException::class, UnknownFormatException::class, HttpException::class, IOException::class)
|
||||
@WorkerThread
|
||||
fun queryRSSResource(url: String, headers: Headers?): Pair<Feed, List<Item>>? {
|
||||
get<AuthInterceptor>().credentials = null
|
||||
|
@ -46,7 +47,7 @@ class LocalRSSDataSource(private val httpClient: OkHttpClient) : KoinComponent {
|
|||
pair
|
||||
}
|
||||
response.code == HttpURLConnection.HTTP_NOT_MODIFIED -> null
|
||||
else -> throw NetworkErrorException("$url returned ${response.code} code : ${response.message}")
|
||||
else -> throw HttpException(response)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.readrops.api.TestUtils
|
|||
import com.readrops.api.apiModule
|
||||
import com.readrops.api.utils.ApiUtils
|
||||
import com.readrops.api.utils.AuthInterceptor
|
||||
import com.readrops.api.utils.exceptions.HttpException
|
||||
import com.readrops.api.utils.exceptions.ParseException
|
||||
import com.readrops.api.utils.exceptions.UnknownFormatException
|
||||
import junit.framework.TestCase.*
|
||||
|
@ -149,7 +150,7 @@ class LocalRSSDataSourceTest : KoinTest {
|
|||
assertNull(pair)
|
||||
}
|
||||
|
||||
@Test(expected = NetworkErrorException::class)
|
||||
@Test(expected = HttpException::class)
|
||||
fun response404Test() {
|
||||
mockServer.enqueue(MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND))
|
||||
|
||||
|
|
Loading…
Reference in New Issue