mita
mita copied to clipboard
RFC: Bugs should directly restart the platform, instead of throwing a catchable exception
Introduction
Yesterday I read an interesting blog post on how Midori-C# handles errors. It boils down to the fact that there are two kinds of errors:
- Exceptions, like "User didn't specify 'http://' in URL"
- Bugs, like indexing beyond the bounds of an array
Both will always be there, however only former can be handled by a program, the latter will never be handleable, since the programmer never expected them in the first place.
Proposal
Make some exceptions no longer exceptional, but instead make them "abandon" the current program, restarting it.
Implementation
On the language generation side, we would need some kind of PlatformGenerator#generateAbandon
or PlatformGenerator#generateRestart
method, that restarts the platform.
On the C-side, most (all) plattforms have some method for restarting, the XDK110 has one: restarting the XDK.
Which kind of bugs really are bugs, and which are catchable is open for debate, but I think that Midori did a pretty good job.