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

Bubble API errors up. #588

Merged
merged 12 commits into from
Oct 14, 2020
Merged

Bubble API errors up. #588

merged 12 commits into from
Oct 14, 2020

Conversation

alex-mechler
Copy link
Contributor

@marcaaron and @cead22 will you review please?

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/142656

Tests

  1. Signed in
  2. Sent a message
  3. Signed out
  4. Signed in again

Screenshots

n/a

return response;
})
.then(response => (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter wanted a blank line here 🙃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move the comment to be outside of the .then() then the blank line before the comment will look nicer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to update the linter to not complain about this when the comment in one level more indented than the previous line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a rule in the linter that would make this pass. Ended up removing the comment, since (imo) it doesn't add a ton to this function overall

tgolen
tgolen previously requested changes Oct 5, 2020
src/lib/API.js Outdated
@@ -105,12 +105,13 @@ function createLogin(login, password) {
* @returns {Promise}
*/
function queueRequest(command, data) {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
// Add the write request to a queue of actions to perform
networkRequestQueue.push({
command,
data,
callback: resolve,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this code a little more consistent, rename callback to resolve.

src/lib/API.js Outdated
@@ -237,6 +210,9 @@ function request(command, parameters, type = 'post') {
if (parametersWithAuthToken.doNotRetry !== true) {
queueRequest(command, parametersWithAuthToken);
}

// Throw an error so we can pass the error up the chain
throw new Error();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify an error message with this error so it's not just a generic error.

src/lib/API.js Outdated
throw new Error(response.message);
}

// Update the authToken so it's used in the call to createLogin below
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Update the authToken so it's used in the call to createLogin below
// Update the authToken so it's used in the call to createLogin below

return response;
})
.then(response => (

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move the comment to be outside of the .then() then the blank line before the comment will look nicer

src/lib/API.js Outdated
Comment on lines 373 to 375
.finally(() => {
Ion.merge(IONKEYS.SESSION, {loading: false});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.finally(() => {
Ion.merge(IONKEYS.SESSION, {loading: false});
});
.finally(() => Ion.merge(IONKEYS.SESSION, {loading: false}));

cead22
cead22 previously approved these changes Oct 5, 2020
Alexander added 2 commits October 5, 2020 11:38
@alex-mechler
Copy link
Contributor Author

Updated

src/lib/API.js Show resolved Hide resolved
@alex-mechler
Copy link
Contributor Author

Updated

marcaaron
marcaaron previously approved these changes Oct 5, 2020
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cead22
cead22 previously approved these changes Oct 6, 2020
src/lib/API.js Outdated
// If the request failed, we need to put the request object back into the queue as long as there is no
// doNotRetry option set in the parametersWithAuthToken
if (parametersWithAuthToken.doNotRetry !== true) {
queueRequest(command, parametersWithAuthToken);
}

// If we already have an error, throw that so we do not swallow it
if (error && error instanceof Error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error && seems unnecessary

@alex-mechler alex-mechler dismissed stale reviews from cead22 and marcaaron via f6d86a3 October 6, 2020 23:56
@marcaaron marcaaron self-requested a review October 6, 2020 23:57
marcaaron
marcaaron previously approved these changes Oct 6, 2020
@alex-mechler
Copy link
Contributor Author

Updated, removed the extra check that wasn't needed

cead22
cead22 previously approved these changes Oct 7, 2020
# Conflicts:
#	src/lib/API.js
@alex-mechler alex-mechler dismissed stale reviews from cead22 and marcaaron via 5d57a86 October 8, 2020 22:18
@alex-mechler
Copy link
Contributor Author

Merge conflicts resolved.

@alex-mechler alex-mechler requested a review from tgolen October 8, 2020 22:23
@tgolen tgolen removed their request for review October 13, 2020 16:37
@Jag96 Jag96 dismissed tgolen’s stale review October 14, 2020 17:57

Requested changes were made and Tim is OOO, dismissing

@Jag96 Jag96 merged commit fced68e into master Oct 14, 2020
@Jag96 Jag96 deleted the amechler-bubble-error branch October 14, 2020 17:58
@MelvinBot MelvinBot mentioned this pull request Jan 29, 2024
50 tasks
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

Successfully merging this pull request may close these issues.

5 participants