[racket-dev] Error message proposal

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jun 21 22:06:56 EDT 2012

At Thu, 21 Jun 2012 05:21:38 -0400, Eli Barzilay wrote:
> To translate the errors you've written (as would be shown by the
> default display handler, when showing all fields too):
>   > (+ 1 'a)
>   +: contract violation
>     `+' expected a number in its 2nd argument; given 'a
>     expected: number?
>     given: 'a
>     argument position: 2
>     other arguments:
>       1
>     context:
>       [...]
>   > (add1 1 2 3)
>   add1: arity mismatch
>     `add1' does not expect 3 arguments
>     expected number of arguments: 1
>     given number of arguments: 3
>     arguments:
>       1
>       2
>       3
>     technical note: this is a contract violation for the application
>       form
>     context:
>       [...]

I don't like the way these example have the error message twice: once
in prose and one in field-and-value form. It's difficult enough to get
either one of those right, but it's particularly difficult to construct
prose right, which is why the new convention encourages relatively
static prose.

I've pushed a set of changes that moves the srcloc back to the front,
codifies a multi-line prose format for the start of a message, codifies
"..." as a suffix for fields that may be too noisy (and that an
environment may choose to hide), and adjusts various existing error

We can change details like the "..." suffix, of course, but that amount
of format/protocol change is about what seems practical and worthwhile
to me.

Meanwhile, we should look more carefully at the content of specific
error messages to see if we can improve either the wording or the
information provided in fields.

Posted on the dev mailing list.