[go: up one dir, main page]

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

non-FuelError Exceptions in request interceptors cause casting errors #840

Open
jonesetc opened this issue Sep 25, 2022 · 0 comments
Open

Comments

@jonesetc
Copy link

Bug Report

Description

When an exception is thrown in a request interceptor, that runtime exception bubbles up until the point that it is assumed (inside of of fuel code) to be a FuelError, is unsafe cast as one, and causes a runtime error at the failed cast.

To Reproduce

Simple code to recreate:

val manager = FuelManager().apply {
    basePath = "https://example.com"
    addRequestInterceptor { { throw RuntimeException("oops") } }
}

runBlocking {
    manager.get("/").awaitStringResult()
}

Will throw error:

class java.lang.RuntimeException cannot be cast to class com.github.kittinunf.fuel.core.FuelError (java.lang.RuntimeException is in module java.base of loader 'bootstrap'; com.github.kittinunf.fuel.core.FuelError is in unnamed module of loader 'app')

Instead of throwing the expected RuntimeException wrapped in a FuelError.

Expected behavior

All non-FuelErrors should be wrapped in a FuelError and be handleable as FuelErrors in the request would be, and not have the failed cast.

Screenshots

N/A

Environment

Development Machine

  • OS: macos and linux
  • IDE: IntelliJ (and running live outside of IDE)
  • Fuel version: 2.3.1
  • Kotlin version: 1.7.10

Smartphone or Emulator

N/A

Additional context

The error is right here:

It seems as simple as changing this to:

.recover {
    if (it is FuelError) Result.Failure(it as FuelError)
    else Result.Failure(FuelError.wrap(it))
}

However I can't seem to get Fuel building locally because of "SDK location not found" at "build.gradle.kts:130" despite having the same JDK 11 set up that I use for everything else. So either feel free to crib that if it makes sense or any direction on how to set up a local build would be great and I'd put up a PR with a test immediately.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant