Earlier quoted context omitted.
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…
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 thi…
Write better error messages
251–260 of 265 posts
Re: Write better error messages
#252Earlier quoted context omitted.
Another one is to generate a globally unique id for that failure. In a web application the user can share the id with you and you can look in the log and see the associated error.
That seems like a good idea, but the problem is that any ID long enough to be sensibly globally unique is likely to be a long string of random-ish characters, and unless the end user has at least a screen cap – highly unlikely – there's about a 0.0001% chance you'll get the code correctly. On the flip side, if you're willing to give up globally unique for "unique enough within and reasonable time frame" then you can…
Re: Write better error messages
#253Earlier quoted context omitted.
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).
> 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. bu…
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
#254Earlier quoted context omitted.
Another one is to generate a globally unique id for that failure. In a web application the user can share the id with you and you can look in the log and see the associated error.
That seems like a good idea, but the problem is that any ID long enough to be sensibly globally unique is likely to be a long string of random-ish characters, and unless the end user has at least a screen cap – highly unlikely – there's about a 0.0001% chance you'll get the code correctly. On the flip side, if you're willing to give up globally unique for "unique enough within and reasonable time frame" then you can…
Re: Write better error messages
#255Earlier quoted context omitted.
What does unreachable()! do actually? I had no idea that was a thing.
It terminates the program with panic! https://doc.rust-lang.org/std/macro.unreachable.html
Re: Write better error messages
#256Earlier quoted context omitted.
This is an attitude I really try to build up in junior devs. Soooo many people seem to default to writing code like, "if input is null return null" (when input should never be null) or "if valueThatShodBePositive I guess this is because no one really teaches error handling. I assume a lot of students end up with a mindset of just make the errors go away instead of, deal with the errors effectively.
I think this is a symptom of using weakly typed languages as well. If your argument types are declared to be options/eithers, then you need to handle the empty case, but usually it's easier and better to just move that optional handling further up the callstack or type system. A lot of `if (input == null)` checks are because you're just not sure whether the argument being passed in will have a value, and it's too muc…
Null checks are totally fine, but it should be clear whether or not null is a valid input to the method. If the answer is 'no' then you should throw ArgumentNullException (or whatever's appropriate for the language), not silently ignore the bad input.
Re: Write better error messages
#257Re: Write better error messages
#258Earlier quoted context omitted.
IBM has done this for decades. For many products, especially on the mainframe, every message has a unique identifier, typically with a prefix for the module or subsystem that generated it, a message number, and an action or severity code, such as “I” for information or “E” for error. A series of Messages and Codes books is supposed to list every message, each with an explanation and suggested user, administrator, or…
Likewise Digital, all VMS error codes are "SUB-S-NAME" (so a permissions error when dealing with a file woule be something like "%RMS-E-NOPERM" (I think that's "rotating mass storage" rather than "Richard M. Stallman"). I think that even harks back to various OSes on the PDP-11, but cannot say for sure.
Now get off my lawn!
Re: Write better error messages
#259Earlier quoted context omitted.
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…
> 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…
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
#260Earlier quoted context omitted.
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 l…
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 lo…