-
Notifications
You must be signed in to change notification settings - Fork 381
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
fix : app crashes on sign up because of a server error #1176
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes made in this PR were tested
locally. Following are the results:
- Code review - Done
- All possible responses (positive and negative tests) were tested as below:
Before : No error message was displayed and the app crashed
After : An error message of "Something went wrong" is displayed
Status of PR : After one more approving review, it will be ready to merge!
@@ -34,6 +34,10 @@ class AuthDataManager(private val dispatcher: CoroutineDispatcher = Dispatchers. | |||
* @return an Observable CustomResponse | |||
*/ | |||
suspend fun register(register: Register): CustomResponse { | |||
return withContext(dispatcher) { apiManager.authService.register(register) } | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert and make changes in CommonUtils.getErrorResponse
because according to the log it's a GSON issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message is "com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $"
it seems like JSON string which return error message has not the correct structure to be parsed into an instance of CustomResponse
Gson is expecting JSON string to begin with an object opening brace. e.g.
{
But the string you have passed to it starts with an open quotes
"
This means that my PR is necessary to avoid this bug due to a server error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but you are throwing a generic exception so there is no way to know why the error actually occurred, for instance even if it is an IOExpection
the snackbar in this case will say something went wrong
. However before the change it would say Please check your internet connection
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the GSON instance you are talking about is in CommonUtils.getErrorResponse
Any updates? |
@vj-codes have you tried sending the request without an active internet connection while testing? |
@yveskalume any updates here? |
@epicadk calling The value of the response variable after calling this is
I think we can just return an instance of replace |
@yveskalume closing the PR due to inactivity. |
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: