Skip to content

Commit 254fd2b

Browse files
committed
add subsections
1 parent fcbdd5f commit 254fd2b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

posts/2021/12/error-message-style-guides.txt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ and contain many great points, I recommend reading them directly! In this
3131
post, I'll try to summarize some common themes or topics that I thought were
3232
particularly interesting.
3333

34-
Several guides (such as Flix and Flow) point out a 80/20 rule: 80% of the times an error message is
35-
read, the developer knows that message well and knows exactly what to do. For
36-
this use case it's important that the message is short. On the other hand, 20%
37-
of the times this same message will have to be understood by a developer who
38-
has never seen it before and is confused, and so the message needs to contain
39-
enough information
40-
to allow them to find out what is going on.
34+
Language Use
35+
------------
4136

4237
Almost all guides stress the need for plain and simple English, as well as
4338
conciseness and clarity [Flix, Racket, Rust, Flow]. Flow suggests to put coding
@@ -53,6 +48,17 @@ Flow suggests to avoid "compiler speak". For example terms like 'token' and
5348
be used (eg "name" is better). The Racket guide goes further and has a list of
5449
allowed technical terms and some prohibited terms.
5550

51+
Structure
52+
---------
53+
54+
Several guides (such as Flix and Flow) point out a 80/20 rule: 80% of the times an error message is
55+
read, the developer knows that message well and knows exactly what to do. For
56+
this use case it's important that the message is short. On the other hand, 20%
57+
of the times this same message will have to be understood by a developer who
58+
has never seen it before and is confused, and so the message needs to contain
59+
enough information
60+
to allow them to find out what is going on.
61+
5662
The Racket guide proposes to use the following general structure for errors:
5763
'State the constraint that was violated ("expected a"), followed by what was
5864
found instead.'
@@ -65,6 +71,9 @@ suggestions altogether because "Students will follow well‐meaning‐but‐wron
6571
advice uncritically, if only because they have no reason to doubt the
6672
authoritative voice of the tool."
6773

74+
Formatting and Source Positions
75+
-------------------------------
76+
6877
The Rust guide suggests to put all identifiers into backticks, Flow formats the error messages using full Markdown.
6978

7079
The Clang, Flow and Rust guides point out the importance of using precise
@@ -73,13 +82,17 @@ compiler information is used in the context of an IDE to show a red squiggly
7382
underline or some other highlighting. The spans should be as small as possible to point out the source of
7483
the error [Flow].
7584

85+
Conclusion
86+
----------
87+
7688
I am quite impressed how advanced and well-thought out the approaches are. I wonder whether it would makes sense for
7789
Python to adopt a (probably minimal, to get started) subset of these ideas as guidelines for its own errors.
7890

7991
.. _`full list`:
8092

8193
Sources
8294
-------
95+
8396
* Rust: https://rustc-dev-guide.rust-lang.org/diagnostics.html
8497

8598
* Clang: https://clang.llvm.org/diagnostics.html

0 commit comments

Comments
 (0)