on master help sign in
move generated JS into try block to report cyclic data errors better

Perhaps the generated JS should move into a function, and the function should be called from within the try block. Not sure!

commitad5b254f7ee8ee367b9b7a42b5ad2e61d716f0e3 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 11 Jul 2019, 12:52 (7 years ago) parent344df5c
1 file changed+7−2
compiler/src/Generate/Html.hs+7−2
compiler/src/Generate/Html.hs+7−2
@@ -38,13 +38,18 @@ You can access it as `app` in the developer console.
3838</pre>
3939
4040<script>
41+try {
4142|] <> javascript <> [r|
4243
43−try {
4444 var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
4545} catch (e) {
4646 // display initialization errors (e.g. bad flags, infinite recursion)
47− document.getElementById("elm").innerText = e;
47+ var header = document.createElement("h1");
48+ header.style.fontFamily = "monospace";
49+ header.innerText = "Initialization Error";
50+ var pre = document.getElementById("elm");
51+ document.body.insertBefore(header, pre);
52+ pre.innerText = e;
4853 throw e;
4954}
5055</script>