Skip to content

Commit

Permalink
fix: Ensure reject on loadImage failed (fix #116) (#128)
Browse files Browse the repository at this point in the history
* fix: Check oImage existence before use fixes #116

* fix: Add rejectMessage for 'loadingImageFailed'

* chore: Add missing message and order messages
  • Loading branch information
junghwan-park committed Jan 18, 2019
1 parent 4be0e6b commit b70dadd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/component/imageLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ImageLoader extends Component {
canvas.setBackgroundImage(img, () => {
const oImage = canvas.backgroundImage;

if (oImage.getElement()) {
if (oImage && oImage.getElement()) {
resolve(oImage);
} else {
reject(rejectMessages.loadingImageFailed);
Expand Down
18 changes: 10 additions & 8 deletions src/js/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,20 @@ module.exports = {
* @type {Object.<string, string>}
*/
rejectMessages: {
addedObject: 'The object is already added.',
flip: 'The flipX and flipY setting values are not changed.',
rotation: 'The current angle is same the old angle.',
loadImage: 'The background image is empty.',
invalidDrawingMode: 'This operation is not supported in the drawing mode.',
invalidParameters: 'Invalid parameters.',
isLock: 'The executing command state is locked.',
undo: 'The promise of undo command is reject.',
redo: 'The promise of redo command is reject.',
invalidDrawingMode: 'This operation is not supported in the drawing mode',
invalidParameters: 'Invalid parameters',
loadImage: 'The background image is empty.',
loadingImageFailed: 'Invalid image loaded.',
noActiveObject: 'There is no active object.',
unsupportedType: 'Unsupported object type',
noObject: 'The object is not in canvas.',
addedObject: 'The object is already added.'
redo: 'The promise of redo command is reject.',
rotation: 'The current angle is same the old angle.',
undo: 'The promise of undo command is reject.',
unsupportedOperation: 'Unsupported operation.',
unsupportedType: 'Unsupported object type.'
},

/**
Expand Down

0 comments on commit b70dadd

Please sign in to comment.