From 866605f7bfcf2934ccea185ed67ada048745fea7 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 3 Oct 2024 13:27:42 +0200 Subject: [PATCH 1/4] Motivational words for errors --- frontend/components/ErrorMessage.js | 47 ++++++++++++++++++++++++----- frontend/treeview.css | 25 +++++++++++++-- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/frontend/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index efc704dba..465166f20 100644 --- a/frontend/components/ErrorMessage.js +++ b/frontend/components/ErrorMessage.js @@ -1,6 +1,6 @@ import { cl } from "../common/ClassTable.js" import { PlutoActionsContext } from "../common/PlutoContext.js" -import { html, useContext, useEffect, useLayoutEffect, useRef, useState } from "../imports/Preact.js" +import { html, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "../imports/Preact.js" import { highlight } from "./CellOutput.js" import { PkgTerminalView } from "./PkgTerminalView.js" import _ from "../imports/lodash.js" @@ -205,10 +205,7 @@ export const ParseError = ({ cell_id, diagnostics }) => { >
${message} -
- ${at} - <${StackFrameFilename} frame=${{ file: "#==#" + cell_id, line }} cell_id=${cell_id} /> -
+
${at}<${StackFrameFilename} frame=${{ file: "#==#" + cell_id, line }} cell_id=${cell_id} />
` )} @@ -423,6 +420,11 @@ export const ErrorMessage = ({ msg, stacktrace, cell_id }) => { ) return html` +
+ Error message + +
+
${matched_rewriter.display(msg)}
${stacktrace.length == 0 || !(matched_rewriter.show_stacktrace?.() ?? true) ? null @@ -443,8 +445,7 @@ export const ErrorMessage = ({ msg, stacktrace, cell_id }) => {
<${Funccall} frame=${frame} />
- ${at} - <${StackFrameFilename} frame=${frame} cell_id=${cell_id} /> + ${at}<${StackFrameFilename} frame=${frame} cell_id=${cell_id} /> <${DocLink} frame=${frame} />
@@ -465,9 +466,41 @@ export const ErrorMessage = ({ msg, stacktrace, cell_id }) => { : null} `} + <${Motivation} stacktrace=${stacktrace} />
` } +const motivational_words = [ + // + "Don't panic!", + "Keep calm, you got this!", + "Silly computer!", + "Silly computer!", + "Probably not your fault!", + "Try asking on Julia Discourse!", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, +] + +const Motivation = ({ stacktrace }) => { + const msg = useMemo(() => { + return motivational_words[Math.floor(Math.random() * motivational_words.length)] + }, [stacktrace]) + + return msg == null ? null : html`
${msg}
` +} + const get_erred_upstreams = ( /** @type {import("./Editor.js").NotebookData?} */ notebook, /** @type {string} */ cell_id, diff --git a/frontend/treeview.css b/frontend/treeview.css index dba349629..a00edee4d 100644 --- a/frontend/treeview.css +++ b/frontend/treeview.css @@ -267,10 +267,14 @@ jlerror > header > p { jlerror > header > p:first-child { font-weight: bold; } -jlerror .stacktrace-header { +jlerror .stacktrace-header, +jlerror .error-header { font-family: var(--system-ui-font-stack); } -jlerror .stacktrace-header > secret-h1 { +jlerror .error-header { + margin-block-end: 1em; +} +jlerror secret-h1 { font-size: 1.9rem; font-weight: 700; } @@ -336,6 +340,9 @@ jlerror > section .frame-source > span { opacity: 0.4; padding: 0px 0.2em; } +jlerror > section .doclink { + user-select: none; +} jlerror li::marker { background: red; @@ -401,6 +408,20 @@ jlerror li .frame-line-preview pre > code:last-of-type:not(.frame-line) { margin-bottom: var(--crop); } +jlerror .dont-panic { + position: absolute; + top: 0; + right: 0; + padding: 0.5em; + background: var(--pluto-logs-debug-color); + color: var(--black); + border-radius: 0.2em; + font-family: var(--system-ui-font-stack); + font-size: 1.2rem; + font-weight: 700; + transform: rotate(6deg); +} + table.pluto-table { table-layout: fixed; } From 826ce2e6be63912f7bcbd00464c5c837b25bcd8b Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 3 Oct 2024 13:46:53 +0200 Subject: [PATCH 2/4] Update ErrorMessage.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: ThΓ©o Galy-Fajou --- frontend/components/ErrorMessage.js | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/frontend/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index 465166f20..e4192fe8d 100644 --- a/frontend/components/ErrorMessage.js +++ b/frontend/components/ErrorMessage.js @@ -474,23 +474,22 @@ const motivational_words = [ // "Don't panic!", "Keep calm, you got this!", + "You got this!", "Silly computer!", "Silly computer!", + "beep boop CRASH πŸ€–", + "computer bad, you GREAT!", "Probably not your fault!", "Try asking on Julia Discourse!", - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, + "uhmmmmmm??!", + "Maybe time for a break? β˜•οΈ", + "Everything is going to be okay!", + "Computers are hard!", + "C'est la vie !", + "Β―\\_(ツ)_/Β―", + "Oh no! πŸ™€", + "this suckz πŸ’£", + ...Array(30).fill(null), ] const Motivation = ({ stacktrace }) => { @@ -498,7 +497,16 @@ const Motivation = ({ stacktrace }) => { return motivational_words[Math.floor(Math.random() * motivational_words.length)] }, [stacktrace]) - return msg == null ? null : html`
${msg}
` + return msg == null + ? null + : html`
{ + window.open("https://discourse.julialang.org/", "_blank")?.focus() + }} + > + ${msg} +
` } const get_erred_upstreams = ( From e408b1f596fb68e9c52b7d8e5986a04b518d44fe Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 3 Oct 2024 13:53:27 +0200 Subject: [PATCH 3/4] dont do when printing or publishing --- frontend/hide-ui.css | 1 + frontend/treeview.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/frontend/hide-ui.css b/frontend/hide-ui.css index f73eab0fa..36085469f 100644 --- a/frontend/hide-ui.css +++ b/frontend/hide-ui.css @@ -28,6 +28,7 @@ pluto-runarea, .MJX_ToolTip, .MJX_HoverRegion, .MJX_LiveRegion, + .dont-panic, nav#undo_delete { display: none !important; } diff --git a/frontend/treeview.css b/frontend/treeview.css index a00edee4d..3d63fe432 100644 --- a/frontend/treeview.css +++ b/frontend/treeview.css @@ -422,6 +422,10 @@ jlerror .dont-panic { transform: rotate(6deg); } +body.disable_ui jlerror .dont-panic { + display: none; +} + table.pluto-table { table-layout: fixed; } From 843163f46959139c98173cf4a4d272784029b21e Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 3 Oct 2024 20:46:57 +0200 Subject: [PATCH 4/4] Update ErrorMessage.js --- frontend/components/ErrorMessage.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index e4192fe8d..d40bc0bc1 100644 --- a/frontend/components/ErrorMessage.js +++ b/frontend/components/ErrorMessage.js @@ -489,6 +489,9 @@ const motivational_words = [ "Β―\\_(ツ)_/Β―", "Oh no! πŸ™€", "this suckz πŸ’£", + "Be patient :)", + // Errors horen erbij + // Ook de pros krijgen errors ...Array(30).fill(null), ]