Skip to content

Commit

Permalink
Merge pull request #5 from collectiveidea/add-service-exception-helpe…
Browse files Browse the repository at this point in the history
…r-for-not-modified

Add a helper to determine if an exception is from a `304 Not Modified` response.
  • Loading branch information
darronschall authored Feb 15, 2023
2 parents 19e771c + d4167ea commit 8b2764a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package com.collectiveidea.twirp

import io.ktor.client.plugins.RedirectResponseException
import io.ktor.client.plugins.ResponseException
import io.ktor.http.HttpStatusCode

class ServiceException(val error: ErrorResponse, responseException: ResponseException) :
RuntimeException(error.msg, responseException)
class ServiceException(val error: ErrorResponse, val responseException: ResponseException) :
RuntimeException(error.msg, responseException) {

fun isNotModifiedException(): Boolean {
return responseException is RedirectResponseException && responseException.response.status == HttpStatusCode.NotModified
}
}

0 comments on commit 8b2764a

Please sign in to comment.