From d3ee40fd5c81a7cfd02fc12f4b6c5da7ccaabd04 Mon Sep 17 00:00:00 2001 From: TheRealJan Date: Mon, 5 Jun 2023 16:17:16 +0200 Subject: [PATCH] Expose error & description in RestException (#180) Signed-off-by: TheRealJan --- buildSrc/src/main/kotlin/Versions.kt | 2 +- .../io/github/jan/supabase/exceptions/RestException.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index ab926fa75..20b4cf151 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,5 +1,5 @@ object Versions { - const val PROJECT = "1.0.2" + const val PROJECT = "1.0.3-dev" } diff --git a/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt b/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt index 2c4ead67e..9daba2088 100644 --- a/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt +++ b/src/commonMain/kotlin/io/github/jan/supabase/exceptions/RestException.kt @@ -5,10 +5,12 @@ import io.ktor.client.statement.request /** * Base class for all response-related exceptions + * @param error The error returned by supabase + * @param description The error description returned by supabase */ -sealed class RestException(message: String): Exception(message) { +sealed class RestException(val error: String, val description: String?, message: String): Exception(message) { - constructor(error: String, response: HttpResponse, message: String? = null): this(""" + constructor(error: String, response: HttpResponse, message: String? = null): this(error, message, """ $error${message?.let { " ($it)" } ?: ""} URL: ${response.request.url} Headers: ${response.request.headers.entries()}