Function fail

Call this to end your program with an error message for the user, and no ugly stack trace. The error message is sent to stderr and the errorlevel is set to non-zero.

This is exception-safe, all cleanup code gets run.

Your program's name is automatically detected from thisExePath.

Note, on DMD 2.064.2, the error message is displayed BEFORE the exception is thrown. So if you catch the Fail exception, the message will have already been displayed. This is due to limitations in the older druntime, and is fixed on DMD 2.065 and up.

Prototype

void fail(T...)(
  T args
);

Example

auto id = 3;
fail("You forgot to provide a destination for id #", id, "!");

// Output on DMD 2.065 and up:
// yourProgramName: ERROR: You forgot to provide a destination for id #3!

// Output on DMD 2.064.2:
// yourProgramName: ERROR: You forgot to provide a destination for id #3!
// scriptlike.fail.Fail

Authors

Nick Sabalausky

Copyright

Copyright (C) 2014-2015 Nick Sabalausky

License

zlib/libpng