diff --git a/lib/gui/pages/main/controllers/image-selection.js b/lib/gui/pages/main/controllers/image-selection.js index 8afdfa11..37882e2e 100644 --- a/lib/gui/pages/main/controllers/image-selection.js +++ b/lib/gui/pages/main/controllers/image-selection.js @@ -124,7 +124,18 @@ module.exports = function( this.selectImageByPath = (imagePath) => { imageStream.getImageMetadata(imagePath) .then(this.selectImage) - .catch(ErrorService.reportException); + .catch((error) => { + const imageError = errors.createUserError({ + title: 'Error opening image', + description: messages.error.openImage({ + imageBasename: path.basename(imagePath), + errorMessage: error.message + }) + }); + + OSDialogService.showError(imageError); + analytics.logException(error); + }); }; /** diff --git a/lib/shared/messages.js b/lib/shared/messages.js index 16b81c3e..1a91e778 100644 --- a/lib/shared/messages.js +++ b/lib/shared/messages.js @@ -87,6 +87,11 @@ module.exports = { invalidImage: _.template('<%= image.path %> is not a supported image type.'), + openImage: _.template([ + 'Something went wrong while opening <%= imageBasename %>\n\n', + 'Error: <%= errorMessage %>' + ].join('')), + elevationRequired: _.template('This should should be run with root/administrator permissions.'), flashFailure: _.template([ diff --git a/tests/image-stream/data/zip/zip-deflate64.zip b/tests/image-stream/data/zip/zip-deflate64.zip new file mode 100644 index 00000000..a9fd4405 Binary files /dev/null and b/tests/image-stream/data/zip/zip-deflate64.zip differ diff --git a/tests/image-stream/tester.js b/tests/image-stream/tester.js index dd654273..ff5ddb80 100644 --- a/tests/image-stream/tester.js +++ b/tests/image-stream/tester.js @@ -50,9 +50,9 @@ exports.expectError = function(file, errorMessage, errorDetail) { m.chai.expect(error.message).to.equal(errorMessage); if (errorDetail) { m.chai.expect(error.description).to.contain(errorDetail); + m.chai.expect(error.description).to.be.a.string; + m.chai.expect(error.description.length > 0).to.be.true; } - m.chai.expect(error.description).to.be.a.string; - m.chai.expect(error.description.length > 0).to.be.true; }); }); }; diff --git a/tests/image-stream/zip.spec.js b/tests/image-stream/zip.spec.js index e9e58d42..7c24a43d 100644 --- a/tests/image-stream/zip.spec.js +++ b/tests/image-stream/zip.spec.js @@ -43,6 +43,12 @@ describe('ImageStream: ZIP', function() { 'Invalid archive image'); }); + describe('given a zip with an unsupported compression method', function() { + tester.expectError( + path.join(ZIP_PATH, 'zip-deflate64.zip'), + 'unsupported compression method: 9'); + }); + describe('given a zip directory containing multiple images', function() { tester.expectError( path.join(ZIP_PATH, 'zip-directory-multiple-images.zip'),