thinking about the concern raised in https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Dealing.20with.20logic.20errors.20in.20Roc about crash being misused by library authors, I wonder if we could decrease the odds of that happening if it had a different name?
for example, unrecoverable might make it more obvious when to use it
or abort, although in that case it might be surprising that it doesn't always abort the process :sweat_smile:
of note, one of the original reasons we decided to name it crash (as I recall) was use cases like quick scripts or coding puzzles like Advent of Code, where handling errors gracefully was just not worth the effort
but now that we've figured out the basic-cli design where you can just leave errors unhandled, and the platform will report them as errors, I think we might not need that use case to be in scope anymore
e.g. in the purity inference world, try will just do the same thing as crash does today (when you're using the "allow unhandled errors" style)
plus try will give a helpful error message by default
You could name it "unreachable" which is the only correct situation to use it in a library. For scripts, it would be ok to "misuse" "unreachable" for a quick exit.
I guess a downside of that approach is that you wouldn't get a stack trace though
which for a quick script would probably be desirable
:thinking: actually platforms could offer to enable stack traces in unhandled errors
at least for I/O operations
not for stuff like List.get
I like the idea of renaming it to be clearer, maybe something even longer like crashBecauseThisIsUnreachable
I think crash does a great job of mediating between "irreversibly stop doing stuff" and not explaining how in the name.
"unreachable" is a descriptor, we should probably have a verb
Abort "misexplains" how it works, which is not great
An obvious alternative is panic, though I understand not wanting to imply we work like Rust since there's no unwind
I would go with: unrecoverableCrash
Cause it is "unrecoverable" within Roc.
It's probably okay if it's clunky
I prefer something concise, but something long like that dissuades usage, which probably isn't a bad thing
Obviously we change the API to:
thisIsDefinitelyABugIfHit "url.to.file.bug.com" "the error message"
I actually kind of like Brendan's suggestion. Thinking what my ideal web server platform would look like, I'd make crash take a couple of required arguments, like a unique error code and a message to the future triager of the error about what they should do with it. That would guarantee a standard format of crash messages appearing in some automated bug tracker.
I wouldn't want to have to provide all those fields for a crash in a simple CLI script though.
That makes me wonder if it should be left up to the platform to provide a crash-equivalent, and if so decide it's name, arguments, exact behavior, etc.
I don’t know if we need error codes. Isn’t the stack trace enough?
Error codes seem more useful for known conditions, but you should model those with Result
Having an error code makes it much easier to correlate if you have the same crash going off multiple times and your logs are sent to a central repository. In that case, the stack trace may be different for each crash for example.
I realize that crash should ideally only be used in unreachable branches, I think in practice we sometimes get it wrong and the result might be a bug of a crash getting reported to some error tracker, say Bugsnag.
One thing I've noticed with error trackers is that it's tricky to group related errors because there's no stable identifier.
crash, because there's no other place where you can stick metadata.That's why for a web server, I would ideally require every crash to get a unique error code, to have an explicit grouping identifier. But I definitely don't want to make the cash it should be required for every platform, that's why I wonder if it's a reasonable thing for the platform to want to define.
update: While I was writing this Kasper just said the same thing much more succinctly :).
One pattern we use at work is to also have a unique ID for a crash occurrence. So when a crash happens, and a user gets an error message in the UI, that error message includes this ID. The ID is attached to the related log message as well, so if the user wants to open a support ticket, they can describe the problem from their point of view and connect it to the relevant logs.
if it's automatically generated, the platform can definitely do that
e.g. the platform could ask the application author to provide a function like onCrash : U64 => Response and then it will call that if your request handler crashes, passing the unique ID it generated, and then you can just do your error reporting and respond with a 500
Last updated: Jun 16 2026 at 16:19 UTC