Conversation
@@ -30,7 +30,8 @@ define([ | |||
url: url, | |||
type: method, | |||
accessToken: accessToken, | |||
data: data | |||
data: data, | |||
timeout: 2500 |
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.
This fixes the subscribe/unsubscribe issue, and returns an error as expected.
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.
Let's make 2500 a named constant like DEFAULT_XHR_TIMEOUT_MS
and allow an override to be passed in to the MarketingEmailClient
constructor.
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.
done!
self.$('.spinner').hide(); | ||
self.displayError(err); | ||
self.$('.spinner').hide(); // <-- I don't think this ever works as intended | ||
self.displayError(err); // <-- This logs to the console, but should actually display .error | ||
return false; |
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.
self returns the proper object (a div with class communication-preferences as expected), but fails to hide the .spinner or display the .error class.
$('.spinner').hide(); | ||
$('.error').html(err).show(); | ||
setTimeout(function() { | ||
self.navigate('/'); |
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.
Let's just inform the user, without doing a redirect, for now.
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.
If the service is unavailable, we should probably hide the subscribe
& unsubscribe
buttons, or just not render them in the first place.
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.
Let's also log any error that occurs, it doesn't look like that is being done unless the user is redirected to /unexpected_error`, which is both unfortunate and unexpected.
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.
If the error is thrown at the /lookup-user, the buttons arent displayed at all. Actually nothing is displayed, so I added only the error message now, is that all right?
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.
@shane-tomlinson I did not get the logging part, I dont see anything being logged for the unexpected_error page.
d8b57ea
to
6392c11
Compare
So, re: https://bugzilla.mozilla.org/show_bug.cgi?id=1182679 it seems our handling of 400 responses needs some work too. |
@jrgm What do you suggest jrgm? Do we consider that a separate issue, or try to fix that in this? I think the former, but let me know if its the latter :) |
return emailPrefs.fetch() | ||
.fail(function (err) { | ||
if (MarketingEmailErrors.is(err, 'UNKNOWN_EMAIL')) { | ||
// user has not yet opted in to Basket yet. Ignore. | ||
return; | ||
} | ||
if (MarketingEmailErrors.is(err, 'SERVICE_UNAVAILABLE')) { |
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.
I think we should remove the if
statement and use this code generically + log to the console.
2ece498
to
1be0c10
Compare
@shane-tomlinson final r? |
@shane-tomlinson @TDA we probably need unit tests for this behaviour |
@vladikoff Isnt there a test for this already in /app/tests/spec/views/settings?
|
ce5317d
to
b4eccc4
Compare
OK, I think this is going to be slightly more complex than I thought. When testing locally, I see the following when opening "communication preferences": The problems:
I'm trying to think of the best way to handle this. I think it will be to save the error to an instance variable, allow the page to display, and in the template, check if there is an error. If an error occurred, then print the error but not the rest of the form. For a reference of another view that does this, see complete_signup.js |
Ahha, complete_signup.js uses self.translateError(err) to handle this. |
b4eccc4
to
1c3f79e
Compare
@shane-tomlinson Should be good to go once Travis and CCI turn green :) |
// View isnt rendered yet, so display the spinner manually. | ||
$('.spinner').hide(); | ||
self._error = self.translateError(err); | ||
return; |
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.
nix this return
efd0435
to
0c17199
Compare
return this.toError('UNEXPECTED_ERROR'); | ||
} | ||
|
||
return this.toError(errObj.errno); | ||
var normalizedError = this.toError(serverError.errno); | ||
normalizedError.code = serverError.code; |
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.
Can you add a comment above this line about what the code represents and why the code is transferred across?
0c17199
to
da8c5db
Compare
Fixes mozilla#2644 set a timeout for ajax requests display error to user and log to console handles both 400 and 500 errors
da8c5db
to
a337b4e
Compare
Manually merged in 70b9df4, closing. |
Fixes #2644
Should be green
@vladikoff
@shane-tomlinson