Skip to content

Commit e52da02

Browse files
committed
Show error message when JS code fails to load
1 parent 84504ab commit e52da02

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

app/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import config from './config/environment';
77
import * as Sentry from './sentry';
88

99
if (typeof FastBoot === 'undefined') {
10+
// eslint-disable-next-line unicorn/prefer-add-event-listener
11+
window.onerror = undefined;
1012
Sentry.init();
1113
}
1214

app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
{{content-for 'body'}}
3030

31+
<script>window.onerror=function(){document.body.innerHTML='<p style="width: 70%;background: var(--main-bg);padding: 10px;">Sorry, it looks like we were not able to load the page. Please make sure your network connection works and you are using an up-to-date browser. If the issue persists, please visit our <a href="https://github.com/rust-lang/crates.io/issues/new/choose">issue tracker</a> to report the problem.</p>'}</script>
3132
<script src="{{rootURL}}assets/vendor.js"></script>
3233
<script src="{{rootURL}}assets/cargo.js"></script>
3334

0 commit comments

Comments
 (0)