-
Notifications
You must be signed in to change notification settings - Fork 34
Error Handling
Maria provides a safe playground for experimentation. Therefore, errors of all sorts must be caught and translated into humane, beginner-friendly language. These errors should be worded gently and should suggest ways to solve the error.
Those interested in how Maria wraps errors should read src/maria/messages.cljs and related namespaces. ๐ค ๐๐พ
When it comes to the fight against opaque error messages, we are stronger together. ๐ช๐พ Please feel free to add to this list!
expressions with single-quoted terms, like (circle 'hello')
slip through undeclared-var
detection and result in "invalid is too many arguments!"
See https://github.com/yogthos/clojure-error-message-catalog/blob/master/cljs/duplicate-case-test-constant.md for an overview of the error.
We currently catch and reword the initial error, but that is only one-third of the total error message. We still are getting an unwanted follow-up looking like:
Duplicate case test constant '1' on line 1 at line 1
Error: Duplicate case test constant '1' on line 1 at line 1
at new cljs$core$ExceptionInfo (http://localhost:3449/js/compiled/out-user-dev/cljs/core.js:35636:10)
at Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (http://localhost:3449/js/compiled/out-user-dev/cljs/core.js:35712:9)
at cljs$core$ex_info (http://localhost:3449/js/compiled/out-user-dev/cljs/core.js:35698:26)
at Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:1073:26)
at cljs$analyzer$error (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:1059:28)
at cljs$analyzer$macroexpand_1 (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:5291:27)
at Function.cljs.analyzer.analyze_seq.cljs$core$IFn$_invoke$arity$4 (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:5365:41)
at cljs$analyzer$analyze_seq (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:5337:34)
at cljs$analyzer$analyze_form (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:5508:34)
at cljs$analyzer$analyze_STAR_ (http://localhost:3449/js/compiled/out-user-dev/cljs/analyzer.js:5549:38)
{:type :overload-arity, :extra {:name twice}}
(inc dec)
causes ""function cljs$core$dec(x){\nreturn (x - (1));\n}1""
(map [1 2 3] inc)
causes console error ๐ฟ, no result ๐ฟ, and a broken environment. ๐ฉ!
(:a "B")
causes "nil" output, even though we'd like to detect attempted use of key lookups on non-maps and suggest alternatives. See https://github.com/yogthos/clojure-error-message-catalog/blob/master/clj/wrong-num-args-passed-to-keyword.md
Similarly, (:first-name "Bob", :last-name "Bobberton")
causes "(intermediate value).cljs$core$IFn$_invoke$arity$3 is not a function\n\nThe function first-name
in the expression above needs a different number of arguments.""
We misreport the cause of this. See https://github.com/yogthos/clojure-error-message-catalog/blob/master/clj/let-requires-even-number-forms.md