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

crash on 401 unauthorized status #5

Closed
iceberg1369 opened this issue Sep 12, 2020 · 11 comments
Closed

crash on 401 unauthorized status #5

iceberg1369 opened this issue Sep 12, 2020 · 11 comments
Assignees
Labels
bug Something isn't working Released Released already on the latest version.

Comments

@iceberg1369
Copy link

iceberg1369 commented Sep 12, 2020

Please complete the following information:

  • Library Version [e.g. v1.0.0]
  • Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0]

Describe the Bug:
when I send A user pass to my api which unauthorized and throws 401 status code. the apiresponse call adapter factory crashed.

--------- beginning of crash

2020-09-12 14:16:55.564 7771-7771/com.skydoves.pokedex E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.skydoves.pokedex, PID: 7771
retrofit2.HttpException: HTTP 401 Response.error()
at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)
at com.skydoves.sandwich.coroutines.ApiResponseCallDelegate$enqueueImpl$1.onResponse(ApiResponseCallDelegate.kt:33)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Add a clear description about the problem.

Expected Behavior:

A clear description of what you expected to happen.

onError expected to be fired

@skydoves
Copy link
Owner

@iceberg1369
Hi, could you let me know about your details of the test codes?

@skydoves skydoves self-assigned this Sep 12, 2020
@skydoves skydoves added the bug Something isn't working label Sep 12, 2020
@iceberg1369
Copy link
Author

iceberg1369 commented Sep 12, 2020

@skydoves

` @provides
@singleton
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
.client(okHttpClient)
//.baseUrl("https://pokeapi.co/api/v2/")
.baseUrl("http://37.152.179.135:8082/")
.addConverterFactory(MoshiConverterFactory.create())
.addCallAdapterFactory(CoroutinesResponseCallAdapterFactory())
.build()
}

@FormUrlEncoded
@post("/api/session")
suspend fun addSession(@field("email") email: String?, @field("password") password: String?): ApiResponse<User?>?

@entity
@parcelize
@JsonClass(generateAdapter = true)
data class User(
@field:Json(name = "disabled") val disabled: Boolean?,
@field:Json(name = "email") val email: String?

) : Parcelable

everything works if I submit vali email and password and model data is emitted. but in case of invalid email and password the 401 status code the app crashes.

@iceberg1369
Copy link
Author

iceberg1369 commented Sep 14, 2020

@skydoves is there anyway to handle errors in sandwitch?

@nevermore1000
Copy link

nevermore1000 commented Sep 14, 2020

I face the same issue,crash on [ApiResponseCallDelegate.kt:33] when HTTP 400 rerurns

@bogdanmunteanu
Copy link

I am facing the same issue : 401 returned instead of onError fired. Commenting to keep tabs on the issue

@skydoves
Copy link
Owner

I will check this issue and release the next version as soon as possible. Thanks!

@AIYO77
Copy link

AIYO77 commented Sep 18, 2020

Hope to have a good solution

@bogdanmunteanu
Copy link

Same thing happening for 500 errors , basically for what isn't in that success codes array in the initializer

@skydoves skydoves added the Released Released already on the latest version. label Sep 19, 2020
@skydoves
Copy link
Owner

Hi, @iceberg1369 @MasterXing @bogdanmunteanu @nevermore1000

Yesterday, released a new version 1.0.5 ! 🎉
Please try to test using the new version.

Thanks for reporting this issue! 👍

@bogdanmunteanu
Copy link

@skydoves , all working great for 401 and all 504 status codes (on error is triggered) . Will test more and come later with more feedback but all seems good for know. Thanks for the fast release 👍

@iceberg1369
Copy link
Author

@skydoves 401 error handled by onError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Released Released already on the latest version.
Projects
None yet
Development

No branches or pull requests

5 participants