scriptlike.fail



class Fail: object.Exception;
This is the exception thrown by fail(). There's no need to create or throw

this directly, but it's public in case you have reason to catch it.

void fail(string msg);
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 std.file.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.

Example:
fail("You forgot to provide a destination!");

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

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



Page generated by Ddoc.