From 78eb454efb993b148d6b36d8b76b9541c3a6526b Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Thu, 3 Oct 2024 20:50:21 +0200 Subject: [PATCH] Error message title --- frontend/components/ErrorMessage.js | 34 +++++++++++++++++++++++------ frontend/treeview.css | 4 ++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/frontend/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index efc704dba..cb9569692 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} />
` )} @@ -227,6 +224,11 @@ const frame_is_important_heuristic = (frame, frame_index, limited_stacktrace, fr return false } + if (funcname.includes("throw")) return false + + // too sciency + if (frame.inlined) return false + if (params == null) { // no type signature... must be some function call that got optimized away or something special // probably not directly relevant @@ -422,7 +424,14 @@ export const ErrorMessage = ({ msg, stacktrace, cell_id }) => { (frame) => !(ignore_location(frame) && ignore_funccall(frame)) ) + const first_package = get_first_package(limited_stacktrace) + return html` +
+ Error message${first_package == null ? null : ` from ${first_package}`} + +
+
${matched_rewriter.display(msg)}
${stacktrace.length == 0 || !(matched_rewriter.show_stacktrace?.() ?? true) ? null @@ -443,8 +452,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} />
@@ -468,6 +476,18 @@ export const ErrorMessage = ({ msg, stacktrace, cell_id }) => {
` } +const get_first_package = (limited_stacktrace) => { + for (let [i, frame] of limited_stacktrace.entries()) { + const frame_cell_id = extract_cell_id(frame.file) + if (frame_cell_id) return undefined + + const important = frame_is_important_heuristic(frame, i, limited_stacktrace, frame_cell_id) + if (!important) continue + + if (frame.source_package) return frame.source_package + } +} + 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..1f9de6ada 100644 --- a/frontend/treeview.css +++ b/frontend/treeview.css @@ -292,6 +292,10 @@ jlerror > section > ol > li { jlerror > section > ol > li:not(.important):not(:hover) { opacity: 0.5; } + +jlerror > section > ol > li:not(.important)::marker { + font-weight: 100; +} jlerror > section > ol > li.from_this_notebook { --bg: var(--jl-info-acccolor); background: var(--bg);