mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
feat(gui): Show friendlier error dialog when opening images (#1557)
* feat(gui): Friendly error dialog when opening image fails This displays a friendlier error dialog if opening an image fails due any reason (like i.e. an unsupported compression method) Change-Type: patch * test(image-stream): Add test for unsupported compression method * test(image-stream): Only check `error.description` when given * test(image-stream): Add zip-deflate64.zip
This commit is contained in:
parent
65210e4cbc
commit
a370e9d4cb
@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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([
|
||||
|
BIN
tests/image-stream/data/zip/zip-deflate64.zip
Normal file
BIN
tests/image-stream/data/zip/zip-deflate64.zip
Normal file
Binary file not shown.
@ -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;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -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'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user