digitalmars.D - tired of not having exit(code), ER proposed
- ketmar via Digitalmars-d (13/13) Sep 28 2014 Hello.
- Dicebot (4/24) Sep 29 2014 What is the benefit of using it over plain C `exit`? Do you rely
- ketmar via Digitalmars-d (4/6) Sep 29 2014 sure, proper cleanup was one of the targets. including catching
Hello. i'm really got tired of writing try/catch boilerplate in main() just to be able to exit from some inner function, setup exitcode and suppress stack trace. so i wrote this small ER: https://issues.dlang.org/show_bug.cgi?id=3D13554 it adds ExitError to core.exception. when runtime catches it, runtime will set error code and exit silently instead of printing error message and stack trace. so now you can avoid wrapping your main in boilerplate try/catch and easily exit from anywhere just by throwing ExitError. sure you still can catch ExitError in your main(), do some cleanup and rethrow it if you want to. it's simple, it's easy, it's handy. happy hacking.
Sep 28 2014
On Monday, 29 September 2014 at 02:30:16 UTC, ketmar via Digitalmars-d wrote:Hello. i'm really got tired of writing try/catch boilerplate in main() just to be able to exit from some inner function, setup exitcode and suppress stack trace. so i wrote this small ER: https://issues.dlang.org/show_bug.cgi?id=13554 it adds ExitError to core.exception. when runtime catches it, runtime will set error code and exit silently instead of printing error message and stack trace. so now you can avoid wrapping your main in boilerplate try/catch and easily exit from anywhere just by throwing ExitError. sure you still can catch ExitError in your main(), do some cleanup and rethrow it if you want to. it's simple, it's easy, it's handy. happy hacking.What is the benefit of using it over plain C `exit`? Do you rely on destructors being called upon program termination?
Sep 29 2014
On Mon, 29 Sep 2014 12:49:41 +0000 Dicebot via Digitalmars-d <digitalmars-d puremagic.com> wrote:What is the benefit of using it over plain C `exit`? Do you rely=20 on destructors being called upon program termination?sure, proper cleanup was one of the targets. including catching ExitError if some additional cleanup needed.
Sep 29 2014