From c1cf254013be001293ad1e8fedb9902ada1c0bd2 Mon Sep 17 00:00:00 2001 From: Joe Masilotti Date: Wed, 20 Mar 2024 09:02:13 -0700 Subject: [PATCH] Add 402: Payment Required --- turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt | 5 +++++ .../test/kotlin/dev/hotwire/turbo/errors/HttpErrorTest.kt | 1 + 2 files changed, 6 insertions(+) diff --git a/turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt b/turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt index 1d56d669..d9b08796 100644 --- a/turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt +++ b/turbo/src/main/kotlin/dev/hotwire/turbo/errors/HttpError.kt @@ -23,6 +23,11 @@ sealed interface HttpError : TurboVisitError { override val reasonPhrase = "Unauthorized" } + data object PaymentRequired : ClientError { + override val statusCode = 402 + override val reasonPhrase = "Payment Required" + } + data object Forbidden : ClientError { override val statusCode = 403 override val reasonPhrase = "Forbidden" diff --git a/turbo/src/test/kotlin/dev/hotwire/turbo/errors/HttpErrorTest.kt b/turbo/src/test/kotlin/dev/hotwire/turbo/errors/HttpErrorTest.kt index 48b680aa..b9be1636 100644 --- a/turbo/src/test/kotlin/dev/hotwire/turbo/errors/HttpErrorTest.kt +++ b/turbo/src/test/kotlin/dev/hotwire/turbo/errors/HttpErrorTest.kt @@ -18,6 +18,7 @@ class HttpErrorTest : BaseUnitTest() { val errors = listOf( 400 to ClientError.BadRequest, 401 to ClientError.Unauthorized, + 402 to ClientError.PaymentRequired, 403 to ClientError.Forbidden, 404 to ClientError.NotFound, 405 to ClientError.MethodNotAllowed,