Skip to content

Commit 8b2764a

Browse files
authored
Merge pull request #5 from collectiveidea/add-service-exception-helper-for-not-modified
Add a helper to determine if an exception is from a `304 Not Modified` response.
2 parents 19e771c + d4167ea commit 8b2764a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package com.collectiveidea.twirp
22

3+
import io.ktor.client.plugins.RedirectResponseException
34
import io.ktor.client.plugins.ResponseException
5+
import io.ktor.http.HttpStatusCode
46

5-
class ServiceException(val error: ErrorResponse, responseException: ResponseException) :
6-
RuntimeException(error.msg, responseException)
7+
class ServiceException(val error: ErrorResponse, val responseException: ResponseException) :
8+
RuntimeException(error.msg, responseException) {
9+
10+
fun isNotModifiedException(): Boolean {
11+
return responseException is RedirectResponseException && responseException.response.status == HttpStatusCode.NotModified
12+
}
13+
}

0 commit comments

Comments
 (0)