about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/embed_modal.js
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2018-04-02 21:51:02 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-04-02 14:51:02 +0200
commit2c51bc0ca5a4c3a4bb140b4b40dabdda859ebb94 (patch)
treedfc6ec5791ab17992f6940da330b3b7193f80ec4 /app/javascript/mastodon/features/ui/components/embed_modal.js
parente7a17167015dca6864f31152c47334c3b3a857a2 (diff)
Add missing rejection handling for Promises (#7008)
* Add eslint-plugin-promise to detect uncaught rejections

* Move alert generation for errors to actions/alert

* Add missing rejection handling for Promises

* Use catch() instead of onReject on then()

Then it will catches rejection from onFulfilled. This detection can be
disabled by `allowThen` option, though.
Diffstat (limited to 'app/javascript/mastodon/features/ui/components/embed_modal.js')
-rw-r--r--app/javascript/mastodon/features/ui/components/embed_modal.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/ui/components/embed_modal.js b/app/javascript/mastodon/features/ui/components/embed_modal.js
index d440a8826..52aab00d0 100644
--- a/app/javascript/mastodon/features/ui/components/embed_modal.js
+++ b/app/javascript/mastodon/features/ui/components/embed_modal.js
@@ -10,6 +10,7 @@ export default class EmbedModal extends ImmutablePureComponent {
   static propTypes = {
     url: PropTypes.string.isRequired,
     onClose: PropTypes.func.isRequired,
+    onError: PropTypes.func.isRequired,
     intl: PropTypes.object.isRequired,
   }
 
@@ -35,6 +36,8 @@ export default class EmbedModal extends ImmutablePureComponent {
       iframeDocument.body.style.margin = 0;
       this.iframe.width  = iframeDocument.body.scrollWidth;
       this.iframe.height = iframeDocument.body.scrollHeight;
+    }).catch(error => {
+      this.props.onError(error);
     });
   }