News for hackers. Stuff that matters.
Re:Write Better Error Messages by hprotagonist on Wednesday October 19, 2022 @09:02AM (#33261512)
I would, if i had any evidence at all that they would be read and acted on. I’m convinced even seemingly competent people are just context blind by any error at all.

In the past month, i’ve had about a dozen interactions like this:

  developer: your service crashed, here’s a screenshot of the last 5 lines of the crash

  me: do you see where the final text you just pasted is “RuntimeError: Did not find ENVVAR, ensure this is set to the proper value (see <internal wiki link>) and then restart this service”

  developer: yeah?

  me: well, did you do that thing?

  developer: what thing?

  me: <headdesk>
and this at work, where the developer in question is intimately acquainted with the context and purpose of the project.
Re:Write Better Error Messages by jimmytidey on Wednesday October 19, 2022 @09:30AM (#33261836)
This is a context where people are used to seeing errors that they don't know what to do with.

If a web app pops a well written error it is much more likely to be acted on than an unmotivated dev seeing a some (probably badly formatted) text.

Every time I see an error in terminal with a link to documentation I'm delighted. And surprised.

Re:Write Better Error Messages by nerdponx on Wednesday October 19, 2022 @09:41AM (#33261985)
So? That's no excuse for a developer to disregard the content of an error message in their own application.
Re:Write Better Error Messages by lijogdfljk on Wednesday October 19, 2022 @10:37AM (#33262873)
It kinda is. Kinda like when documentation is so repeatedly outdated and incorrect, that when you need new information you just skip documentation entirely.

Are you wrong for skipping documentation? Yea, maybe. Is it entirely expected? Yea.

Based on the parent comment, at least.

Re:Write Better Error Messages by monknomo on Wednesday October 19, 2022 @11:00AM (#33263222)
And yet developers do disregard the content of error messages. Try to figure out why they disregard it. I doubt the answer is "because they're stupid". The answer probably also isn't "because they just aren't trying".

What could it be? Why do people read things and react in similar ways, even if they have different jobs? If only there was some field of study that could answer these mysteries.

Re:Write Better Error Messages by Kalium on Wednesday October 19, 2022 @10:59AM (#33263220)
Once upon a time, I worked at a financial startup (the company is irrelevant). I created a little harness around a static analysis tool. It would fail builds when a library had an outstanding vulnerability scored as HIGH or SEVERE with a patch available. The harness put a friendly error message around it. It ran roughly as follows:

> Hi! If you're reading this message, it's likely because this tool failed your build. To understand why and fix it, please click this link <link_to_internal_doc>. Below is a table that lists the packages you need to update and the version you need to update them to.

The doc had at the very top in big flashing red text with siren anigifs a link to the portion that explained that they needed to update their libraries with very clear copy-paste-into-Dockerfile actionable guidance. The page also explained the broader context, such as the point of the tool and why we were doing this despite having a firewall and so on.

This is where you might be delighted and surprised.

What was perhaps less delightful and surprising were the consequences for me. About 4-6 times a week, I would then have a Slack conversation akin to this:

    Dev: Why did you break my build!?!

    Me: Can I see the error message?

    Dev: <pastes message above>

    Me: Thanks! Looking at the message, is there something unclear about the documentation? Does it not work?

    <ten minutes pass>

    Dev: Nope! Docs are great!
At this point the conversation would end.
Re:Write Better Error Messages by grandinj on Wednesday October 19, 2022 @09:29AM (#33261824)
Some developers are just lazy, and will likely need some kind of negative feedback to force them to confront their own laziness.

Which can be tricky, because the degree of negative feedback that is appropriate to the person in question can range from

"Polite one-on-one suggestion that you read the error message more than once before calling me"

to

"Full on yelling at the person in the middle of an open-plan office".

Thankfully, type II is rare, but they do occur.

Re:Write Better Error Messages by lupire on Wednesday October 19, 2022 @09:48AM (#33262084)
Send a link to wiki. Last line of page is "if you have questions, reach out and include the keyword $THIS_PAGE_KEY in your message."
Re:Write Better Error Messages by bartread on Wednesday October 19, 2022 @10:07AM (#33262397)
> Some developers are just lazy

I'm really lazy: if I were on the receiving end of emails with error messages that included instructions about how to fix said error I'd automate Freshdesk (or whatever ticketing system I was using) to respond with instructions specific to that error message, in the first instance, along with a note to get in touch again if that didn't solve the problem. I'd also set the ticket to autoresolve after a set period of time.

Re:Write Better Error Messages by ajnin on Wednesday October 19, 2022 @09:14AM (#33261645)
How many interactions didn't you have, because the developer read the error message, read the Wiki, and ultimately solved the issue themselves ?
Re:Write Better Error Messages by Kalium on Wednesday October 19, 2022 @11:35AM (#33263728)
If my experience doing something very similar and armed with Confluence-powered wiki page readership tracking is any guide, a lot fewer than you might think.
Re:Write Better Error Messages by chillfox on Wednesday October 19, 2022 @09:37AM (#33261936)
Don't send people somewhere else to learn how to fix the error. The more steps and indirection you add the fewer people will bother doing it themselves, especially if they can bump it to the developer. Make it easy for people to fix their own problems by being explicit, direct and complete. List all the steps and use formatting to make it visually easier to consume.

So your error message while a far cry from the worst I have seen is also pretty far from the good ones I have seen.

Re:Write Better Error Messages by starkd on Wednesday October 19, 2022 @09:42AM (#33261997)
I think his point was the developer tends not to even investigate the ENVVAR at issue or visit the link. If the developer does investigate the link and still has an issue, than you have a point.
Re:Write Better Error Messages by chillfox on Wednesday October 19, 2022 @10:02AM (#33262293)
Pretty sure his problem was he got contacted about an issue he considers uninteresting, and his preferred solution is the user stops behaving like a human.

Reaching for the easiest way to solve a problem first is a very human thing to do, and in this case he was easier to contact than opening up a browser and reading an article that presumably is written in the same kind of language as the error message.

Re:Write Better Error Messages by starkd on Wednesday October 19, 2022 @10:29AM (#33262750)
I admit to doing this. Even many of the useful error messages that clearly indicate the fix are drowned out out by the mass of output. I've made this mistake before, and I'll probably do so again.
Re:Write Better Error Messages by chillfox on Wednesday October 19, 2022 @10:33AM (#33262809)
I feel like this is a problem of overly chatty application logs + lack of formatting for errors.

If the volume of drivel was lowered and errors were formatted with spacing and color to stand out, then they would be easier to focus on.

So log errors to stderr, send it to a separate log file, and format it well (use multiple lines).

Re:Write Better Error Messages by marcosdumay on Wednesday October 19, 2022 @04:37PM (#33267629)
> So log errors to stderr, send it to a separate log file, and format it well (use multiple lines).

Oh, for sure. Do never:

- send errors to the same log you send normal activity.

- default into logging things that aren't errors on the error log (make this possible to override if you want, but never the default).

- log the errors there, but the necessary context on stdout so it appears correct on a terminal. (E.g. build tools that print entering into target in stdout; error in stderr; leaving target in stdout)

- try to recover just to show a different error later.

Re:Write Better Error Messages by randomswede on Thursday October 20, 2022 @09:20AM (#33274277)
Oh, boy, on the "never log expected failures as errors" front, I once worked with a database system that used opportunistic transactions. Basically, each modification to a row carried effectively the original value of that trow with the update and if it failed, the API call triggered an error saying that the transaction failed. So if you did a "SET column=(column+1) WHERE rowid=unique", the client could basically do an automatic retry.

But, it also logged each and every occurrence of this at "Error" severity, instead of at "Info" severity (it is, after all, expected to happen once in a while).

And of course, once our code switched over to using this, the first few times every team member had to deal with a production issue, the immediate reaction was "oh, no, the data store is unhealthy! look at this mass of error logs, I can see one every few minutes!". Thankfully, after the first team member (me, as it happens) spent half an hour reading the relevant parts of the design and implementation docs, we could frequently short-cut a lengthy investigation by "oh, you think $DB is bad because you are seeing transaction failures? no, that's expected, see $URL".

Re:Write Better Error Messages by dvtrn on Wednesday October 19, 2022 @10:18AM (#33262573)
I’m left wonder at what point does the “give a man a fish/teach a man how to fish” method of pedagogy apply in terms of ‘acting like a human’ in this context?

Asking as someone who otherwise generally agrees that there are some truly poorly written errors and exceptions out there, but has also been on the admittedly frustrating end of the constant requests for help deciphering error messages that were very plainly stating what the problem is for someone who didn’t even try looking for the fishing rod.

Re:Write Better Error Messages by chillfox on Wednesday October 19, 2022 @10:29AM (#33262754)
Sure, clearly there are people who will never try, or learn, but in general as an industry I feel like the wast majority of errors are very very far from good.

Few error messages are written well, has good formatting and are self contained (can be used to fix the issue without having to seek further information elsewhere). Sometimes you see errors that contain one of those elements, but rarely all of them.

There has been an effort the last few years improving compiler errors for some languages, but those same improvements have not reached applications.

Re:Write Better Error Messages by zagrebian on Wednesday October 19, 2022 @09:14AM (#33261657)
This just means that the error message needs to be more clear. For example, after the error itself, it could give direct advice: “PERFORM THESE STEPS: You must define ENVVAR. Go to <wiki link>. Set ENVVAR to a proper value and restart the service.”

Notice the direct language. It reads like an order. The less direct the message, the higher the chances that the user will not act upon it.

Re:Write Better Error Messages by mariusmg on Wednesday October 19, 2022 @09:23AM (#33261761)
>it could give direct advice: “PERFORM THESE STEPS: You must define ENVVAR. Go to <wiki link>. Set ENVVAR to a proper value and restart the service.”

Really, should logs also be documentation now ? Just mindlessly logging the same "advice" over and over again each time the error happen ?

Re:Write Better Error Messages by ddulaney on Wednesday October 19, 2022 @09:36AM (#33261922)
Logs can definitely be a form of documentation.

I write software that is generally run low in the stack, quietly doing some mundane tasks that are business-critical but rarely thought about. If one of our clients has to mess with our software beyond the occasional update, that was a failing. Not all software is like this, but lots of it is -- its value is that no human needs to be involved.

I need to write log messages with the expectation of an audience who doesn't know much about the software -- it's been running uninterrupted for months or years and suddenly something has gone wrong. If the log line doesn't tell the user how to solve their problem, I will end up getting a call.

Re:Write Better Error Messages by throw827474737 on Wednesday October 19, 2022 @09:56AM (#33262196)
If it is that simple, the why doesn't the code fix it itself? But no, usually there is 1/2/3 likely things, but it also could be anything else.. and that kind if unexpected errors even often have no default-fix.

No, the most best thing is to point to the documentation which has that, and not printig out manpages of docs in error messages now.

> I write software that is generally run low in the stack

What stack, how low? Me too.. that low that I usually cannot return or even log a " see error code doc at http.." string for various reasons (bandwidth, mem, performance) but only have error codes ;)

Re:Write Better Error Messages by pwinnski on Wednesday October 19, 2022 @12:37PM (#33264646)
In the case at hand, where an environment variable isn't set, how exactly should the code fix itself? Human interaction is necessary, which is the reason the log message should spell out what the human needs to do.

If I'm starting a service and see a pointer in the logs to documentation, that seems like an incredibly broken approach to me. Why would I look at missing or out-of-date documentation that may or may not be at hand when the code that knows the problem is right there and can just tell me? A log message like you're describing might as well say, "Something went wrong, but I don't want to tell you what. Instead check page 43 of the document in the third file cabinet from the left in that room over there on your right. No, your other right."

Re:Write Better Error Messages by samus on Friday October 21, 2022 @04:00AM (#33285657)
Similar issues arises with such documentation in error messages. There now has to be a process to make sure that all such information is always accounted for and updated correspondingly when the system changes.

> Something went wrong, but I don't want to tell you what.

is somewhat disingenius of an example. Error logs should tell in exhausting detail what went wrong. Ops needs that to analyse the situation, and the vendor will have much less trouble reproducing the error. However, suggesting specific fixes could be disastrous. Furthermore, documentation should already be in a form that operations can be expected to work with also in crisis situations.

Re:Write Better Error Messages by an_ko on Wednesday October 19, 2022 @12:47PM (#33264772)
I don't want to have to hunt for documentation if it breaks. It may have been 30 years and everything but the binary has been lost, and the vendor is out of business. If in that situation all I get is an error code and a link to documentation that doesn't exist, I'd have to start reverse-engineering. And while doing so I'd definitely be cursing the coder who decided that saving a couple hundred bytes of space in a log file in the event of an "abort the program"-severity event was worth dumping this in my lap.
Re:Write Better Error Messages by samus on Friday October 21, 2022 @03:27AM (#33285460)
Running such software is asking for a disaster already. At least documentation should still exist, and operational frameworks like ITIL insist on that. It can happen, but is usually telling of an operational culture that disregards maintenance, counting on being able to kick the can down the road as long as possible.
Re:Write Better Error Messages by dementiapatent on Wednesday October 19, 2022 @09:29AM (#33261826)
It will be so much fun when the implementation is refactored and half of these comments are forgotten about and no longer meaningful.
Re:Write Better Error Messages by prerok on Wednesday October 19, 2022 @11:01AM (#33263247)
Exactly. At one of my previous workplaces there was a cumulative effect of misattributed error messages so the actions to perform were often of no help.

Not even to mention the fact that new or changed error messages caused a landslide in costs in translations to various languages. I guess this product has no localization? At that time, when I was working at such a product that had it, we had to go through a deliberate process to describe why we want to change it, what the impact is, etc. Tell me you want 100 new messages and you will be stuck in meetings for the next month.

In their case, though, it seems they at least have the support in management for it. I hope it turns out better for them than it did for me.

Re:Write Better Error Messages by SpicyLemonZest on Wednesday October 19, 2022 @11:36AM (#33263733)
I had an error message a few months ago that instructed me to reinstall the AWS CLI, I filed a ticket when that didn't work, and the team was annoyed with me because obviously the real problem was a Python configuration warning with no suggested action 10 lines up.
Re:Write Better Error Messages by chillfox on Wednesday October 19, 2022 @09:43AM (#33262017)
Yes! We have tools to filter what gets saved and compression that handles repeated text very well.

So why not provide docs on how to solve the error along with the error.

Re:Write Better Error Messages by kortex on Wednesday October 19, 2022 @10:07AM (#33262381)
It depends who, what, and when the error is about. Failures are generally a bathtub curve. You have a high rate at start (usually configuration issues), some fairly fixed rate during operation, and then more at end of lifecycle (exhaustion, service hiccups on scale-in).

If it's in the early lifecycle, absolutely, because it's most actionable. X is set wrong, Y can't be reached, etc, guide whoever is operating the system how to fix it.

If it's mid cycle, it's often post-hoc, but context is worth its weight in gold. Less about telling the operator how to fix and more about why it broke, to avoid in the future.

End of cycle, whatever.

Re:Write Better Error Messages by Spivak on Wednesday October 19, 2022 @10:29AM (#33262757)
Errors on initialization, fatal errors, and non-recurrent errors that require human/support intervention should be documentation.
Re:Write Better Error Messages by hinkley on Wednesday October 19, 2022 @11:04AM (#33263285)
If the error results in the program shutting down, it’s once per fatal interaction.

In other words, yes.

Re:Write Better Error Messages by 0xbadcafebee on Wednesday October 19, 2022 @11:33AM (#33263695)
Logs actually are a form of documentation. Documentation can provide instructions on how to diagnose and fix problems, and that's what logs do: tell a human being what a problem is and how to fix it.

Remember that often the person reading the logs is not the person who wrote the software. Maybe it's an Ops person at 2AM trying to fix a broken deploy. Maybe it's a developer who joined the company 3 years after the software was written. Maybe the log is passing through an error message from 3 layers deep in the stack. The more literate your logs are, the better.

Re:Write Better Error Messages by eyelidlessness on Wednesday October 19, 2022 @12:33PM (#33264588)
This is fairly common in good error logs.
Re:Write Better Error Messages by pwinnski on Wednesday October 19, 2022 @12:34PM (#33264599)
Yes!

There are people who don't read formal documentation but do read logs, after all.

If the advice is the same over and over again, then yes, give the advice over and over again. I wouldn't want to assume that someone has read every line of the logs, or has started to read top-to-bottom, so the advice should always be among the most recent lines in the log, and the only way to ensure that is to give the advice again each time the error happens.

Re:Write Better Error Messages by xboxnolifes on Wednesday October 19, 2022 @08:17PM (#33269418)
Should logs more clearly let the user know how to fix problems? Yes.
Re:Write Better Error Messages by ckozlowski on Wednesday October 19, 2022 @09:33AM (#33261873)
I think you're correct. To add to this (and I think it's the point that the article was trying to make), errors written in fragmented language or "developer speak" I feel are likely to get glossed over. The “Write it like you’re talking to a friend.” advice the article gives I think is spot on. Making the message more conversational is to invite better understanding and comprehension.

I feel there's a trend when it comes to disseminating messaging like this that we adopt an attitude of our audience "is smart, and should figure the rest out". They may be. But they already have lots to do any plenty to figure out. Any opportunity we, the requestor, can lighten their mental load, is going to increase the odds that they'll be inclined to take action right away.

Re:Write Better Error Messages by dvtrn on Wednesday October 19, 2022 @09:20AM (#33261717)
I’m not seeing how what the message already is any less direct or clear than what you’re saying it should be? It straight up tells you it can’t find the var and what to do about it.

Can you help me understand what isn’t clear about the message as is, or maybe point out the ambiguity to someone who just isn’t seeing it? I want to write better error messages but I share the frustration of the above poster. The message tells you specifically what to do, but you’re coming back saying it’s not clear.

Re:Write Better Error Messages by lupire on Wednesday October 19, 2022 @09:38AM (#33261946)
Some people don't read anything that isn't an all-caps command. They have learned helplessness from seeing too much useless error text in the past.
Re:Write Better Error Messages by j-bos on Wednesday October 19, 2022 @09:27AM (#33261809)
I think the original error is quite clear, under normal circumstances.

Not OP but I've noticed that people often get brain fog when something goes wrong and are often need BIG, SHORT, WORDS to shake out of it. Or really anything that can shake them out of the 'idunno' state of mind.

But maybe if something like that became standard ut would no longet be a context switcher..

Re:Write Better Error Messages by ckozlowski on Wednesday October 19, 2022 @09:36AM (#33261920)
I think you're spot on, and I made a similar comment above.

It's easy to say "they can figure it out". Sure, in a restful state. But the people we're asking to take action already have a lot on their plate. Using plain, conversational language whenever possible with exceedingly clear steps means less mental exertion on the receiver. And since we need their help, anything we can do to make it easier on their end helps us.

Re:Write Better Error Messages by dvtrn on Wednesday October 19, 2022 @09:47AM (#33262072)
These are fascinating responses to me, as with the example given my mind first went to someone for whom English is a second language. that group having trouble with this message I would understand, or at least have an easier time understanding having trouble, if even a very little amount.

For someone who was born speaking English and spoke it their entire lives, the example provided couldn’t possibly be more to the point in my opinion.

Though I agree overall with the general idea and that yes there are some pretty baffling and downright awfully written error messages and log entries that take a minute to grok (I just don’t think the example replied to is one of them).

Re:Write Better Error Messages by Too on Wednesday October 19, 2022 @01:27PM (#33265297)
Conversational errors can also be fatiguing. Often what you want is something short and dry that can be pattern matched. Compilers are pretty good at this because all their errors start the same way.

    Error in file foo/bar.c, line 32, missing semicolon. 
No conversation needed. These can then be complemented with more conversational language on the next line to explain why semicolon is needed. Rust is quite good at this.
Re:Write Better Error Messages by randomswede on Thursday October 20, 2022 @09:07AM (#33274092)
Then there's the delightful (no, I actually mean the opposite) errors that g++ emitted (back when I last wrote C++ and compiled using g++), where I basically could go "OK, there is an error that was detected at line L, in file F; and I think it may be a type error", so a recompile with clang, so I can actually understand what the error was, so I could fix it.
Re:Write Better Error Messages by pydry on Wednesday October 19, 2022 @09:25AM (#33261783)
It more likely means that the developer views the service as OP's responsibility. They'll view an order as something OP needs to do.

The clarity of the error message doesnt really matter if the recipient believes it is intended for somebody else.

Re:Write Better Error Messages by MiddleMan5 on Wednesday October 19, 2022 @09:48AM (#33262090)
I can't tell if this is sarcasm or not, this is obviously highlighting a deeper issue in developer culture.

The example given was clear compared to 90% of other error messages, and saying that it needs to be "more clear" is almost dismissive

Re:Write Better Error Messages by Aperocky on Wednesday October 19, 2022 @10:36AM (#33262862)
Don't blame developer culture, if that error cannot be acted on, attribute to incompetence and not culture.
Re:Write Better Error Messages by duxup on Wednesday October 19, 2022 @09:55AM (#33262184)
The problem is people are not rational… and we try to solve that with software.

Many people just lock up when software doesn’t do what they expect.

Re:Write Better Error Messages by vbezhenar on Wednesday October 19, 2022 @10:03AM (#33262319)
Not rational people must be fired from IT.
Re:Write Better Error Messages by duxup on Wednesday October 19, 2022 @10:04AM (#33262332)
Generally a pipe dream in my experience.
Re:Write Better Error Messages by hinkley on Wednesday October 19, 2022 @11:07AM (#33263324)
Lots of people find ways to irrationalize being rational.
Re:Write Better Error Messages by bombcar on Wednesday October 19, 2022 @11:02AM (#33263263)
Some of the errors that Gentoo portage can encounter do exactly this - and they do it with beautiful terminal colors that make it easy to figure out what you need to run, or where to go to figure out which of the three options you need.

The problem can come when there's a wall of "useless" logging/error messages, and the last one or near the last one is the actual important one to look at. You have to explicitly call it out on a clear screen and make it obvious - and even then, people won't always read it.

Re:Write Better Error Messages by bee_rider on Wednesday October 19, 2022 @11:37AM (#33263753)
There's a type of error for which the user can be given detailed step-by-step instructions (permission issues, etc). But to some extent, errors should handle situations the programmer didn't expect. If it is possible to provide detailed step-by-step fixes, then the program should do those steps itself.

Adding a URL might not be a great plan, never know how long an old copy of a program will stick around, might not control that website forever.

Re:Write Better Error Messages by lupire on Wednesday October 19, 2022 @09:39AM (#33261958)
Use the error messages you wrote! Send them the link they sent you, and move on.
Re:Write Better Error Messages by residualmind on Wednesday October 19, 2022 @09:13AM (#33261639)
Actually reading (and understanding, acting upon) error messages seems to be part of the learning process of every developer. And while more senior devs usually do read error messages, even they sometimes, rather than reading it will jump to behavior like "trying again a different way", before looking closely what went wrong.
Re:Write Better Error Messages by hinkley on Wednesday October 19, 2022 @11:10AM (#33263367)
Developers often seemed shocked that people can’t find the important error in a wall of text. A particular peeve is when the same error is reported three ways and the real error is sandwiched between others or scrolled off the screen due to spammy behavior.
Re:Write Better Error Messages by Joker_vD on Wednesday October 19, 2022 @09:16AM (#33261676)
Well, imagine the error was simply "RuntimeError: Environment variable not set" instead, then how much of your time would have been wasted by those dozen interactions?
Re:Write Better Error Messages by rjmill on Wednesday October 19, 2022 @10:39AM (#33262900)
> evidence at all that they would be read

I just had an idea: Put tracking info in the error URL. If your company has an internal URL shortener, that could do the trick.

More practically, I feel like it helps to put an empty line before the call to action. For many people, a traceback is just noise. The empty line helps split the useful info out from the traceback.

Or if it's a script/CLI (and you know the error reason) don't even show a traceback. Just print the error message to stderr, exit non-zero, and be done with it.

Re:Write Better Error Messages by JTbane on Wednesday October 19, 2022 @10:51AM (#33263070)
>>>“RuntimeError: Did not find ENVVAR, ensure this is set to the proper value (see <internal wiki link>) and then restart this service”

I'm laughing as you could not make it clearer if you tried. PEBKAC

Re:Write Better Error Messages by nkrisc on Wednesday October 19, 2022 @10:55AM (#33263155)
The goal of writing better error messages isn't to help the people who never read error messages, it's to help the people who do and who you never have to hear from.
Re:Write Better Error Messages by marklubi on Wednesday October 19, 2022 @11:00AM (#33263233)
The trick that I've found is that each error message needs to be unique... not just the stack trace, but the actual wording of the message leading up to that.

Get a screenshot or the exact verbatim of it, and you can identify exactly where in the code it originated.

User reports are unreliable, but when I can pinpoint where the message originated from, it massively cuts down on the troubleshooting time.

Re:Write Better Error Messages by alisonatwork on Wednesday October 19, 2022 @11:17AM (#33263474)
A useful thing here is not just to include a unique error code for the type of error (usually numeric), but also to generate some kind of short Base32 or similar hash and print that right next to the error message while logging it to your normal back end. Then whether people send you a screen shot, copy/paste, whatever, you can easily search the logs to find the exact event that occurred.
Re:Write Better Error Messages by mceachen on Wednesday October 19, 2022 @12:41PM (#33264689)
Better still: add a unique prefix to the error code, so it's googlable.

The Typescript team does this with compilation errors, like `TS12345: frobulating types cannot be transmuted`.

Re:Write Better Error Messages by rmetzler on Wednesday October 19, 2022 @02:13PM (#33265863)
Yes, that type of thing is pretty useful for linters. These error codes act as identifiers if you need to google them and whenever you need to configure the linter the way you like it or for one-off exceptions.
Re:Write Better Error Messages by legulere on Wednesday October 19, 2022 @11:11AM (#33263386)
In RFC 7807 all errors get an unique URI. Message texts might change or be translated into a language you don’t understand.
Re:Write Better Error Messages by BerislavLopac on Wednesday October 19, 2022 @12:17PM (#33264365)
To be precise, each error type gets a unique URI.

A good way to take advantage of that is to have a central database of all error types, but not many companies bother to do that.

Re:Write Better Error Messages by mi_lk on Wednesday October 19, 2022 @12:43PM (#33264729)
> have a central database of all error types

do you have any example?

Re:Write Better Error Messages by zem on Wednesday October 19, 2022 @01:01PM (#33264942)
here's ours for pytype (a python type checker): https://google.github.io/pytype/errors.html
Re:Write Better Error Messages by shadowgovt on Wednesday October 19, 2022 @03:20PM (#33266694)
It turns out translating error messages is controversial.

Users, upon hitting an error, often go check Stack Overflow. If you localize your error messages, you Balkanize the collective wisdom on how to address the error (which will always be larger than your team's ability to troubleshoot errors and offer correctives in your documentation and FAQs).

Re:Write Better Error Messages by Too on Wednesday October 19, 2022 @01:10PM (#33265055)
About that, the number of developers that can’t read, or even understand the value of, a stack trace is also astonishing.

If only I had a penny every time someone sent me a “log of the error”, that only contains the final line with the unhelpful message saying nothing but KeyError.

Re:Write Better Error Messages by vladvasiliu on Wednesday October 19, 2022 @01:19PM (#33265168)
Forget stack traces.

I've met multiple "web developers" (actually working on the backend or "full-stack", building API servers and whatnot) who came complaining about this or that server being "unreachable" and could I check it's up / whether the firewall allows them through. Only to find they were getting HTTP 404 errors or the like. Which were explicit in the errors they'd show me.

Re:Write Better Error Messages by lamontcg on Wednesday October 19, 2022 @02:13PM (#33265868)
At prior work we removed stack traces from the default error output because it was thought to "scare" too many users.

Then for years almost without fail when an error was pasted into a GH issue it would include the big "If submitting a bug report, please include the full stack trace at /var/log/stacktrace.out" message--without the stacktrace. I added some whitespace and all caps to it and still nobody read it.

Re:Write Better Error Messages by dylan604 on Wednesday October 19, 2022 @01:53PM (#33265635)
I used to lean on line numbers, but those quickly fall out of sync with deployed code and what's currently checked out and available for immediate debugging. I've also switched to using unique text you mention as it will always find the place in the code regardless if it has been moved.

I wish I had learned that earlier than I had.

Re:Write Better Error Messages by lucb1e on Wednesday October 19, 2022 @05:55PM (#33268364)
> each error message needs to be unique

Include random numbers. "Error 7743929" is super easy to track down (grep -r 7743929 takes 2 seconds to type), you don't need a NATO alphabet to understand what they're saying on the phone in order to be able to search it correctly, its general purpose is understood internationally, and it won't change between versions (like when you'd encode a file name and line number, for example). When I first figured this out at, idk, 17 years old and mentioned the idea in a game making forum, people called me crazy, but I still use it and don't know of any better system.

Of course, this is alongside an actual error message to help the user help themselves. This is just to trace the line where it originated, which already helps a lot for small software projects like I make.

Re:Write Better Error Messages by EvanAnderson on Wednesday October 19, 2022 @12:28PM (#33264517)
I am reminded of the classic non-intuitive survivorship bias example from WWII re: armoring bombers: https://en.wikipedia.org/wiki/Survivorship_bias#In_the_milit...
Re:Write Better Error Messages by vkou on Wednesday October 19, 2022 @12:52PM (#33264824)
Or, in the anecdote above, to help yourself, when you are inevitably contacted by the person who never reads error messages.
Re:Write Better Error Messages by coldacid on Wednesday October 19, 2022 @11:00AM (#33263234)
The help desk guys are on the other side of a cubicle wall from my workstation, and almost every call I overhear about someone getting errors just convinces me further and further that people don't only not pay attention to the error message, they don't pay attention to the people they're calling to help them get through the situation either.
Re:Write Better Error Messages by TillE on Wednesday October 19, 2022 @11:05AM (#33263300)
I've seen this constantly over the years, people who absolutely refuse to read the simplest instructions, but instead require step-by-step hand-holding from you personally.

I have no idea how these people get through life at all.

Re:Write Better Error Messages by dagw on Wednesday October 19, 2022 @11:08AM (#33263333)
I suspect that, at least subconsciously, they're to some extent doing that to punish you for writing 'bad' software that they have to struggle with. If they're going to suffer, you're going to suffer right along side them.
Re:Write Better Error Messages by 0x457 on Wednesday October 19, 2022 @03:59PM (#33267246)
Hey, let's jump on a quick call, so we can go through this together and maybe update docs if they're out of date?
Re:Write Better Error Messages by nicbou on Wednesday October 19, 2022 @09:30PM (#33269861)
I have no idea either.

For example when someone asks me "how do I get a German work visa" and I reply with a link to a page titled "how to get a German work visa", which is the among the first results on Google. A literal minute later, they ask me more questions that the page clearly answers.

Some people can't be arsed to read a 5 minute article you hand-delivered to them, and would rather have you type it back to them.

I think that some people just have zero respect for other people's time.

Re:Write Better Error Messages by onion2k on Wednesday October 19, 2022 @11:10AM (#33263351)
Shouldn't the app gracefully exit with a clear message, and not bail out in a way that looks like a crash? I'd guess that the person who wrote it hooked into the error handler because that was the easy thing to do rather than bother to write a nice way to exit properly.

The fact that you've had this a dozen times points to a problem with the app more than the people using it to me.

Re:Write Better Error Messages by 0xbadcafebee on Wednesday October 19, 2022 @11:23AM (#33263558)
The problem is here: "RuntimeError:". Once they saw that, they stopped reading. "Did not find ENVVAR" [..] "ensure this is set to the proper value" [..] "and then restart the service" are also obscure and will stop them from reading.

Why is the user like this? Error message PTSD. Years of staring at obscure errors full of technical jargon that are not helpful to the user, has left them scared to even look at the content of the error message. They have tried to Google these things before and failed, and now they just avoid it entirely and run for help.

I'm sure there's enough detail in the link you provided to help the user. But if that's the case, it will be better for the error message to simply say:

  A problem occurred, but don't worry! You can fix it yourself in 5 minutes! For instructions, visit https://internal-wiki-link/spaces/BLAH/AppUserRuntimeError#A013579
Even if you expect the user to be "smart enough" to fix their own problem, they are more likely to try it themselves if you make it seem easier.
Re:Write Better Error Messages by Kalium on Wednesday October 19, 2022 @11:52AM (#33263967)
I tried exactly this approach! What I got was a bunch of developers copy-pasting the error message with helpful URL at me and demanding to know what they should do. The number who followed the link and fixed the problem themselves was shockingly small.

Going out on a limb, I think we're all going astray by trying to parse the error messages our fellow developers are reacting to. A great many seem to handle any unfamiliar or unexpected error message by giving up, no matter how friendly or informative or helpful it may be.

Re:Write Better Error Messages by bonoboTP on Wednesday October 19, 2022 @12:44PM (#33264736)
They don't parse the error message as a natural language sentence talking to them. They take it as an opaque string, like a big error code. It literally passes through them without getting interpreted.

They learned that the affordances of these error messages are copy pasting into some place: a google search box, or a chat box asking for help. But it has no affordance of "interpret as an English sentence" for them.

Re:Write Better Error Messages by 0xbadcafebee on Wednesday October 19, 2022 @12:46PM (#33264750)
If that's the case, then these people may just need training. It's likely that nobody has ever sat them down and explained that they have a responsibility to investigate their own issue. Often people feel they have to rush to get something done, and that they can't take time to troubleshoot. But if their bosses explained that, actually, it's fine if your work is a little late due to troubleshooting, they might do it themselves more often. You also may need to provide back-pressure by interacting via email/ticket.
Re:Write Better Error Messages by Kalium on Wednesday October 19, 2022 @01:12PM (#33265086)
That's a kind, caring, compassionate, empathetic approach founded on assuming good faith.

Unfortunately, it is perhaps not an ideal fit. I was mostly not dealing with the most junior and new of developers here. I was often dealing with senior developers who fully understood that they were responsible for investigating their own issues in a context where it was understood that troubleshooting takes time.

I often wound up regurgitating the error message back to them, asking them to point to the problems in the documentation getting in the way of them solving their own problems. This generally resulted in a conspicuous silence and the issues shortly thereafter being resolved.

The lesson I drew from this was not that the developers in question needed training. What I learned was that they needed to be convinced to treat these errors as natural-language strings they could interpret themselves.

Re:Write Better Error Messages by Taylor_OD on Wednesday October 19, 2022 @11:28AM (#33263623)
It's a little annoying but to be fair because most error messaging is garbage, its easy to start to ignore them. How often is the error message shown, and the little fix given, actually going to solve the problem in modern web development? 10% of the time? 25% of the time? I'd be shocked if its that high.
Re:Write Better Error Messages by quintussss on Wednesday October 19, 2022 @11:34AM (#33263708)
Isn't this just survivor bias though? You only hear from those that fail to read and act on the error message.
Re:Write Better Error Messages by bonoboTP on Wednesday October 19, 2022 @12:38PM (#33264650)
It's error message blindness, similar to ad blindness. Even if you make a great banner ad with some very useful information, or the perfect and affordable product for my life I won't see it because I mentally filter out ads because they are junk most of the time.

Some people develop the same with relation to error messages because most of them are not actionable, other than "stuff broke somehow, [gibberish] blabla". Even if your error message is impeccable, it's in the class of things that are noise.

If you come up to me at some busy tourist location, where I'm used to lots of scammers, I won't listen to you even if you are actually a nice person and just want to have a nice chat and we would be compatible friends.

Often it is a good strategy to just ask people. Documentation and comments get out of date very fast. If you are the kind of person who reads everything meticulously and googles around, reads manuals etc. you may be wasting a lot of time. Of course there is a right balance to find. Some people err too much on the side of not thinking themselves and immediately asking for handholding, but overall it's often the right thing to do.

In many cases I found that trying to reason out what was going on was hopeless, because when I eventually gave up and asked someone, it turned out that the solution was unguessable, something like "ah of course, that things is out of date, do this magic incantation, then this and that, yeah we should update the docs sometime!".

A lot of knowledge is locked up inside people's brains and just spreads around as "rumors" on the grapevine. Is that state of affairs ideal? No. But it's realistic and people are going to adapt by asking first, thinking second.

Re:Write Better Error Messages by BlargMcLarg on Wednesday October 19, 2022 @12:57PM (#33264895)
Asking people is mostly bad habits from a culture too ingrained into the whole 'ask first' thing, and often times it is the people trying to help that are to blame.

I had this recently. Many individuals like to play hero and make sure I don't get stuck because their business is an undocumented mess. Before I even read the thing and tried, they are already trying to give me the answer. When I ask 'is this documented and if so, how would it be discovered easily' their first reaction is 'no' followed by a lengthy explanation which should be in the wiki and easy for newcomers to find.

And it shows when I forget a few days later because my brain never put in the effort to get to the answer and my memory is that of a fruit fly's.

Re:Write Better Error Messages by Jiro on Wednesday October 19, 2022 @01:43PM (#33265497)
There's also the situation where the program creator likes changing functionality on a whim, and every time you google up your problem, you find a solution for a version of the software that doesn't have the particular menu or whatever that you had the problem with.

(This is a big problem if you've ever had a problem with Android.)

Re:Write Better Error Messages by outworlder on Wednesday October 19, 2022 @12:58PM (#33264914)
I have managed to get a lot of notoriety in my company by just:

1. Paying attention to error messages

2. Reading documentation

3. Looking up stuff I don't fully understand(including googling error messages)

That's it.

Some people don't even read error messages at all. I understand non technical people doing that, but I've seen far too many engineers doing it. If anything doesn't go exactly as expected, they freeze. I have no idea how a person gets so far in their careers without reading error messages. Actually, I do, those people ask others to figure out stuff for them. That's way prevalent in enterprise settings. Sure, collaboration is good, but I've seen a lot of instances where there's a massive imbalance – you'll have 10 people pinging a single person to 'unblock' them. They could have spent a couple of minutes trying to figure out yourself.

I'll move mountains to help someone that comes to me after having done some basic homework to try to fix (or at least triage) an issue. It very rare though.

It's also amazing how many people will just go ahead without having read a single line of documentation of the thing they are working on. I've even had a developer dive in a Golang codebase without having _ever_ worked on the language. That would have been fine – that's how I learn new languages, just get accustomed, before doing some more formal training and exercises – except that he continued to not read the language documentation before asking a bunch of questions. Needless to say, the questions weren't good.

And number 3... just rubber ducky everything. If you can't explain it, you don't get it. Go read up on the topic. Sometimes I'll find out that I don't fully understand something as I'm writing an email to others.

Re:Write Better Error Messages by vladvasiliu on Wednesday October 19, 2022 @01:22PM (#33265216)
> I'll move mountains to help someone that comes to me after having done some basic homework to try to fix (or at least triage) an issue. It very rare though.

This. I actually am OK with people not figuring out even basic stuff. But please, at least try to give the impression that you've put some effort in, instead of just trying to have me do your homework while you browse facebook or whatever.

Re:Write Better Error Messages by tetha on Wednesday October 19, 2022 @03:52PM (#33267156)
> I'll move mountains to help someone that comes to me after having done some basic homework to try to fix (or at least triage) an issue. It very rare though.

These are rare, but they also tend to be the really effective ones. We have a couple of teams who understand the stack, read documentation and read error messages. We generally don't hear of them for months and months, because they are too busy being productive.

But when we hear of them, it's usually time to push boundaries of the infrastructure and the processes. They tried everything and nothing worked and now it's time to make it work.

Re:Write Better Error Messages by dan_mctree on Wednesday October 19, 2022 @05:30PM (#33268165)
> except that he continued to not read the language documentation before asking a bunch of questions

Can't really blame people for that too much, most language documentation is utterly unreadable unless you already know exactly what you're doing. And even if you do get it, it's in one eye and out the other. Most people just don't learn very well from reading technical information you don't need to use right away. You might be a happy exception and got to build up your notoriety that way

Re:Write Better Error Messages by samus on Friday October 21, 2022 @02:40AM (#33285204)
This doesn't hold for any popular language. For those, a bazillion tutorials in various formats, books and example projects have been written.

Language documentation is for looking up nitty-gritty details. You go there if you already know what you're looking for. It works for some languages and for some people, but reading it from top to bottom is usually a horrible way to learn a programming language.

Re:Write Better Error Messages by tlogan on Wednesday October 19, 2022 @01:36PM (#33265388)
My favorite ones are (and we get them at least once a week):

  user: "your service does not work. here is a screenshot"

  me: "the screenshot says: please upgrade"

  user: "I do not want to upgrade"

  me: <headdesk>
Re:Write Better Error Messages by CityCobra on Wednesday October 19, 2022 @01:55PM (#33265661)
Still, if you write proper error messages then at least you can figure out what the issue was without SSHing into the person’s computer and checking their logs.
Re:Write Better Error Messages by bob1029 on Wednesday October 19, 2022 @01:57PM (#33265696)
This is a lesson I learned while being system owner of the primary user interface that runs on a semiconductor factory floor. No amount of confirmation/warning dialogs will actually stop someone from doing a wrong thing. Doesn't matter how scary the language is. Here's an approximate sample of one:

  "DANGER! Confirming this action may result in 8 figures worth of scrap!!!"
Even if you are super careful and make sure your error messages are terse in all cases, you will still succumb to things like muscle memory among your users. I've caught myself mindlessly dismissing these while testing. How can I expect my users to be better than the person who developed the UI? That is unreasonable.

It got to a point where we started removing these alerts/confirmations because it was training people to do the wrong thing in a few places. If you have part of a UI where all actions are immediate and final, the game theory changes. The moment a user enters into one of these spaces, they are much more cautious.

If the user thinks the UI will save them, they may eventually tire of these protections and forget why they are there in the first place. I feel like this is very similar to the problem of driver assistance and partial self-driving capabilities today.

Re:Write Better Error Messages by nicbou on Wednesday October 19, 2022 @09:32PM (#33269877)
I like how GitHub asks you to type back the name of the repository you want to delete.
Re:Write Better Error Messages by bob1029 on Thursday October 20, 2022 @05:18AM (#33272371)
For GitHub scary actions, I will not hesitate to copy and paste the expected repo name on the UI. I can do this so quickly my brain does not process the consequences in time.
Re:Write Better Error Messages by pizza on Wednesday October 19, 2022 @02:12PM (#33265850)
I mean it kinda makes sense. When you're coding, you're constructing something. When you're debugging, you're deconstructing something. I feel like it's natural for people to take a sec to codeswitch, bc they were likely in a state of flow w/ considerable momentum up until they saw the error
Re:Write Better Error Messages by llbeansandrice on Wednesday October 19, 2022 @02:12PM (#33265859)
I feel like I can't get folks to open the log file and cmd-F "ERROR" half the time.
Re:Write Better Error Messages by tlogan on Wednesday October 19, 2022 @02:14PM (#33265880)
This is 100% correct.

In theory, all errors should: explain the input, explain the problem and explain how to solve the problem (actions). And that should help and reduce number of support calls. However, error messages and actions how to solve the error are read by maybe 1% of users.

The only way to improve your UI is to prevent errors and use standards / familiar design.