[C, Linux] playdate->system->error doesn't pause simulator or otherwise behave as expected


In my code I have an ERROR macro defined that I've been using to report fatal errors like nonrecoverable allocation failures, assumptions not being met, etc. It's defined like so (initializing pd is the first thing done in the kEventInit callback):

extern const PlaydateAPI *pd;
// ...
#define ERROR_FMT(fmt, ...)  pd->system->error("%s:%zu(%s): " fmt, __FILE__, __LINE__, __func__, __VA_ARGS__)
// since there's no portable way to have a variadic macro where the varargs are optional
#define ERROR(msg)  ERROR_FMT("%s", msg)

When I first wrote it using pd->system->error I assumed it would function the same as when an error occurs in Lua code—i.e. on the simulator it's paused and on the device it crashes with a useful error screen—since that's approximately what's described by the documentation:

Calls the log function, outputting an error in red to the console, then pauses execution.

Inside Playdate with C: playdate->system->error

However, while it does output an error in red to the console, it doesn't do anything other than that on the simulator. I've tested it in both the init code run in eventHandler on kEventInit and in my update callback and in no situation is it paused.

Thanks for the report. The linux simulator should pause, we'll get that fixed. As for halting the device, it should be. I'll look into that. Thanks again.

I just tested this on the up-coming OS release and calling error() on device resulted in a crash with the error text in the "more info" screen. Not sure why it's not working for you, but at least it seems to work in the next release.

Hmm, you're right that it does actually crash on device with information when I copied the Hello World C example and added an error() call, there must be an unexpected interaction in with my code that's causing it to not (my fault naturally). But yes, it still does not pause the simulator as expected.