Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a helper to determine if an exception is from a 304 Not Modified response. #5

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}