Skip to content

Fix error response payload parsing #1874

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

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/email-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export default Component.extend({
await ajax(`/api/v1/users/${user.id}/resend`, { method: 'PUT' });
this.set('disableResend', true);
} catch (error) {
if (error.payload) {
if (error.errors) {
this.set('isError', true);
this.set('emailError', `Error in resending message: ${error.payload.errors[0].detail}`);
this.set('emailError', `Error in resending message: ${error.errors[0].detail}`);
} else {
this.set('isError', true);
this.set('emailError', 'Unknown error in resending message');
Expand Down
8 changes: 4 additions & 4 deletions app/components/pending-owner-invite-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default Component.extend({
this.set('isAccepted', true);
} catch (error) {
this.set('isError', true);
if (error.payload) {
this.set('inviteError', `Error in accepting invite: ${error.payload.errors[0].detail}`);
if (error.errors) {
this.set('inviteError', `Error in accepting invite: ${error.errors[0].detail}`);
} else {
this.set('inviteError', 'Error in accepting invite');
}
Expand All @@ -31,8 +31,8 @@ export default Component.extend({
this.set('isDeclined', true);
} catch (error) {
this.set('isError', true);
if (error.payload) {
this.set('inviteError', `Error in declining invite: ${error.payload.errors[0].detail}`);
if (error.errors) {
this.set('inviteError', `Error in declining invite: ${error.errors[0].detail}`);
} else {
this.set('inviteError', 'Error in declining invite');
}
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/crate/owners.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default Controller.extend({
await this.crate.inviteOwner(username);
this.set('invited', `An invite has been sent to ${username}`);
} catch (error) {
if (error.payload) {
this.set('error', `Error sending invite: ${error.payload.errors[0].detail}`);
if (error.errors) {
this.set('error', `Error sending invite: ${error.errors[0].detail}`);
} else {
this.set('error', 'Error sending invite');
}
Expand All @@ -40,8 +40,8 @@ export default Controller.extend({

this.get('crate.owner_user').removeObject(user);
} catch (error) {
if (error.payload) {
this.set('removed', `Error removing owner: ${error.payload.errors[0].detail}`);
if (error.errors) {
this.set('removed', `Error removing owner: ${error.errors[0].detail}`);
} else {
this.set('removed', 'Error removing owner');
}
Expand Down
4 changes: 2 additions & 2 deletions app/routes/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default Route.extend({
});
}
} catch (error) {
if (error.payload) {
this.flashMessages.queue(`Error in email confirmation: ${error.payload.errors[0].detail}`);
if (error.errors) {
this.flashMessages.queue(`Error in email confirmation: ${error.errors[0].detail}`);
return this.replaceWith('index');
} else {
this.flashMessages.queue(`Unknown error in email confirmation`);
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/crate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ module('Acceptance | crate page', function(hooks) {
await click('#add-owner');

assert.dom('.error').exists();
assert.dom('.error').hasText('Error sending invite');
assert.dom('.error').hasText('Error sending invite: Not Found');
assert.dom('.owners .row').exists({ count: 2 });
});

Expand Down