Skip to content
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

Allow error message to be display in notice #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,15 @@ export default class ImageTool {
*/
uploadingFailed(errorText) {
console.log('Image Tool: uploading failed because of', errorText);


let errorMessage = 'Can not upload an image, try another.';
let errorJson = JSON.parse(errorText);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to parse JSON, because it is already parsed in the method above. Use the errorText argument instead.

if (errorJson.hasOwnProperty('message')) {
errorMessage = errorJson.message;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, update a readme describing that feature

this.api.notifier.show({
message: 'Can not upload an image, try another',
message: errorMessage,
style: 'error'
});
this.ui.hidePreloader();
Expand Down