Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Raise full error for bad responses in Kotlin SDK #1411

Open
tjbanghart opened this issue Dec 12, 2023 · 0 comments
Open

Raise full error for bad responses in Kotlin SDK #1411

tjbanghart opened this issue Dec 12, 2023 · 0 comments
Assignees
Labels

Comments

@tjbanghart
Copy link
Member

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())
    }
}
@tjbanghart tjbanghart self-assigned this Dec 12, 2023
@github-actions github-actions bot added p3 Priority 3 need triage labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant