Skip to content

Raise full error for bad responses in Kotlin SDK #1411

@tjbanghart

Description

@tjbanghart

We are missing helpful errors in the ok helper method.

We should turn this

fun <T> ok(response: SDKResponse): T {
    @Suppress("UNCHECKED_CAST")
    when (response) {
        is SDKResponse.SDKErrorResponse<*> -> throw Error(response.value.toString())
        is SDKResponse.SDKSuccessResponse<*> -> return response.value as T
        else -> throw Error("Fail!!")
    }
}

into

fun <T> ok(response: SDKResponse): T {
    @Suppress("UNCHECKED_CAST")
    when (response) {
        is SDKResponse.SDKErrorResponse<*> -> throw Error(response.value.toString())
        is SDKResponse.SDKSuccessResponse<*> -> return response.value as T
        is SDKResponse.SDKError -> throw Error(response.message)
        else -> throw Error(response.toString())
    }
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature requestkotlinKotlin SDK issuesp3Priority 3

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions