Skip to content

Commit d18555b

Browse files
authored
Merge pull request #956 from supabase-community/postgrest-exception-fix
Fix serialization exception occurring when `PostgrestRestException#details` is not a String
2 parents 6d85c03 + f54125f commit d18555b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package io.github.jan.supabase.postgrest
22

33
import kotlinx.serialization.Serializable
4+
import kotlinx.serialization.json.JsonElement
45

56
@Serializable
67
internal data class PostgrestErrorResponse(
78
val message: String,
89
val hint: String? = null,
9-
val details: String? = null,
10+
val details: JsonElement? = null,
1011
val code: String? = null,
1112
)

Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/exception/PostgrestRestException.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.jan.supabase.postgrest.exception
22

33
import io.github.jan.supabase.exceptions.RestException
44
import io.ktor.client.statement.HttpResponse
5+
import kotlinx.serialization.json.JsonElement
56

67
/**
78
* Exception thrown when a Postgrest request fails
@@ -14,7 +15,10 @@ import io.ktor.client.statement.HttpResponse
1415
class PostgrestRestException(
1516
message: String,
1617
val hint: String?,
17-
val details: String?,
18+
val details: JsonElement?,
1819
val code: String?,
1920
response: HttpResponse
20-
): RestException(message, hint ?: details, response)
21+
): RestException(message, """
22+
|Hint: $hint
23+
|Details: $details
24+
""".trimIndent(), response)

0 commit comments

Comments
 (0)