anitab-org / mentorship-android

Mentorship System is an application that matches women in tech to mentor each other, on career development, through 1:1 relations during a certain period of time. This is the Android application of this project.
https://github.com/anitab-org/mentorship-android/raw/apk/app-debug.apk
GNU General Public License v3.0
165 stars 379 forks source link

fix : app crashes on sign up because of a server error #1176

Closed yveskalume closed 2 years ago

yveskalume commented 2 years ago

Description

Fixes #1175

Type of Change:

Code/Quality Assurance Only

How Has This Been Tested?

open the app > go to Sign Up screen > complete the informations > click on Sign Up button > and see the error message without the app crashing

Checklist:

epicadk commented 2 years ago

Any updates?

epicadk commented 2 years ago

@vj-codes have you tried sending the request without an active internet connection while testing?

epicadk commented 2 years ago

@YvesKalume any updates here?

yveskalume commented 2 years ago

@epicadk calling httpException.response()?.errorBody()?.string() is returning HTML instead of JSON.

The value of the response variable after calling this is

<html>
    <head>
        <title>Internal Server Error</title>
    </head>
    <body>
        <h1><p>Internal Server Error</p></h1>
    </body>
</html>

I think we can just return an instance of CustomResponse with the error message in the constructor instead of using gson :

replace return gson.fromJson(response.toString(), CustomResponse::class.java) with return CustomResponse(response.toString())

vj-codes commented 2 years ago

@YvesKalume closing the PR due to inactivity. Thank you for your contribution:)