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
enhancement New feature request kotlin Kotlin SDK issues p3 Priority 3

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
@jeremytchang jeremytchang added enhancement New feature request kotlin Kotlin SDK issues and removed need triage labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request kotlin Kotlin SDK issues p3 Priority 3
Projects
None yet
Development

No branches or pull requests

2 participants