mita icon indicating copy to clipboard operation
mita copied to clipboard

RFC: Bugs should directly restart the platform, instead of throwing a catchable exception

Open wegendt-bosch opened this issue 6 years ago • 0 comments

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.

wegendt-bosch avatar Apr 25 '18 14:04 wegendt-bosch