In the old Roc compiler, I liked the fact that the main! function could return any error, and it would just be printed out. Now every error has to be mapped to Exit(U32). This is arguably a good thing for production software, but for dev and quick scripts, I find it a bit cumbersome. Perhaps there could be an option to enable the old behavior, for example: roc --dev foo.roc?
Hmm, I thought this was up to the platform author. It looks like basic-CLI is still wired up to do this but I haven’t tested it recently so I could be wrong.
Oh thanks, I didn't know it was up to the platform author, that makes sense. So I guess that's a question for @Luke Boswell ?
I'm actually about to do some other stuff with basic-cli so I could test it while I'm at it
Btw, the basic CLI platform used to provide Utc.now!, Utc.to_nanos_since_epoch, and Sleep.millis!. It would be great to add these back if possible.
And maybe Http.send! as well?
I'm testing with v0.21.0 released 2 days ago, and it appears that it allows arbitrary errors like you want. If you return an error other than Exit(I32) it prints a message and then just does Str.inspect on whatever error you returned.
Oh great, I didn't know 0.21.0 was released, I'll try it out now.
Yeah I just noticed the new release myself :sweat_smile:
Looks like it also has Utc.now!
At a minimum the Tcp api changed a bit, not sure what else.
Wowowowow
Yeah I thought it had sleep and those other functions. Ive got work things on today and cant really look at it closely.
Aurélien Geron said:
In the old Roc compiler, I liked the fact that the
main!function could return any error, and it would just be printed out. Now every error has to be mapped toExit(U32). This is arguably a good thing for production software, but for dev and quick scripts, I find it a bit cumbersome. Perhaps there could be an option to enable the old behavior, for example:roc --dev foo.roc?
I'd like to go back to that old design. So the return type of main! becomes Try({}, Exit(I32), ..) and then the platform does a match on that Try with other => crash "The CLI crashed with:\n\n${other.inspect()}"
The nice thing about it is if you want the current API, it's trivial to get - just have main! call a function with that narrower signature and you're all set.
It looks like that is the way basic-cli is working currently, except that instead of crashing with a message it's logging to stderr and exiting with 1
that also works!
Last updated: Aug 12 2026 at 12:35 UTC