Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit 336ae8f

Browse files
committed
simplify error messaging for install failures (bug 790492)
1 parent a5f88f8 commit 336ae8f

File tree

2 files changed

+23
-57
lines changed

2 files changed

+23
-57
lines changed

hearth/media/js/buttons.js

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -59,61 +59,7 @@ define('buttons', ['browser', 'format', 'l10n', 'z'], function(browser, format,
5959
z.apps[product.manifest_url] = z.state.mozApps[product.manifest_url] = installer;
6060
setButton($button, gettext('Launch'), 'launch install');
6161
}).on('app_purchase_error app_install_error', function(e, installer, product, msg) {
62-
var $button = getButton(product),
63-
errSummary;
64-
65-
console.error('Error code:', msg);
66-
67-
switch (msg) {
68-
// mozApps error codes, defined in
69-
// https://developer.mozilla.org/en-US/docs/Apps/Apps_JavaScript_API/Error_object
70-
case 'MKT_CANCELLED':
71-
case 'DENIED':
72-
msg = 'cancelled';
73-
break;
74-
case 'MANIFEST_URL_ERROR':
75-
errSummary = gettext('The manifest could not be found at the given location.');
76-
break;
77-
case 'NETWORK_ERROR':
78-
errSummary = gettext('App host could not be reached.');
79-
break;
80-
case 'MANIFEST_PARSE_ERROR':
81-
errSummary = gettext('App manifest is unparsable.');
82-
break;
83-
case 'INVALID_MANIFEST':
84-
errSummary = gettext('App manifest is invalid.');
85-
break;
86-
// Marketplace specific error codes.
87-
case 'MKT_SERVER_ERROR':
88-
errSummary = gettext('Internal server error.');
89-
break;
90-
case 'MKT_INSTALL_ERROR':
91-
errSummary = gettext('Internal server error on app installation.');
92-
break;
93-
default:
94-
errSummary = gettext('Install failed. Please try again later.');
95-
break;
96-
}
97-
98-
if (msg && msg != 'cancelled') {
99-
var $btnContainer = $('.app-install');
100-
setButton($button, gettext('Error'), 'error');
101-
102-
if ($btnContainer.length) { // Reviewers page.
103-
var $errList = $('<ul class="errorlist"></ul>');
104-
$errList.append(format.format('<li>{0}</li>', errSummary));
105-
$btnContainer.find('.errorlist').remove();
106-
$btnContainer.append($errList);
107-
} else {
108-
$button.trigger('notify', {
109-
title: gettext('Error'),
110-
msg: errSummary
111-
});
112-
}
113-
} else {
114-
// Cancelled install. Roll back.
115-
revertButton($button);
116-
}
62+
revertButton($('button.installing'));
11763
}).on('buttons.overlay_dismissed', function() {
11864
// Dismissed error. Roll back.
11965
revertButton($('.button.error'));

hearth/media/js/install.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Hey there! I know how to install apps. Buttons are dumb now.
22

33
define(
4-
['apps', 'capabilities', 'payments/payments', 'requests', 'user', 'z'],
5-
function(apps, caps, payments, requests, user, z) {
4+
['apps', 'capabilities', 'notification', 'payments/payments', 'requests', 'user', 'z'],
5+
function(apps, caps, notification, payments, requests, user, z) {
66
'use strict';
77

88
function launchHandler(e) {
@@ -93,6 +93,26 @@ define(
9393
}
9494

9595
function installError(installer, product, msg) {
96+
console.log('error: ' + msg);
97+
98+
switch (msg) {
99+
// mozApps error codes, defined in
100+
// https://developer.mozilla.org/en-US/docs/Apps/Apps_JavaScript_API/Error_object
101+
case 'MKT_CANCELLED':
102+
case 'DENIED':
103+
case 'MANIFEST_URL_ERROR':
104+
case 'NETWORK_ERROR':
105+
case 'MANIFEST_PARSE_ERROR':
106+
case 'INVALID_MANIFEST':
107+
break;
108+
// Marketplace specific error codes.
109+
default:
110+
notification.notification({
111+
message: gettext('Install failed. Please try again later.')
112+
});
113+
break;
114+
}
115+
96116
z.win.trigger('app_install_error', [installer, product, msg]);
97117
}
98118

0 commit comments

Comments
 (0)