Exceptions on Windows being "swallowed"
Mike Parker
aldacron at gmail.com
Wed Nov 27 04:11:44 UTC 2019
On Wednesday, 27 November 2019 at 02:48:53 UTC, cartland wrote:
> Trying out exception handling. When an exception occurs,
> program seems to just exit.
>
> dub -a x86_mscoff
I compiled it with dmd and ran it directly from the command line
and it worked fine:
C:\dev\D\scratch>ex
finally
catch %sfirst
done
Did you try that? And do you have the MS linker installed or are
you using the lld that ships with DMD?
Two things regarding your code:
writeln does no formatting. You want writefln for that. But with
writeln, you can provide multiple string arguments and they will
be concatenated into the final output, like this:
writeln("catch ", e.msg);
Also, you don't need the `int main` signature if you don't
actually need the return value to signify anyting:
void main() { }}
is just fine.
More information about the Digitalmars-d-learn
mailing list