refactor: check for .message in verification error #1443
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Across nearly all APIs in this repo, the server returns a JSON with a
message
key when an error occurs. However, the Verification module is an exception, as it returns one of a set of custom strings (e.g.'SEND_OTP_FAILED'
, 'INVALID_OTP
'), and the frontend contains a switch statement to determine what error message to display.We want APIs to behave consistently, so it would be good for the Verification module to return error objects in the form
{ message: 'some error message' }
. However, this would be a backwards-incompatible change as the current frontend would render the entire JSON object instead of just the message string.Solution
This PR ensures that the API change will be backwards-compatible by checking for a
message
property on the error. #1440 will address the actual API change.