*! version 0.1, 02oct2014

Title

capass -- Extends assert by throwing error messages

Syntax

capass
exp [if] [in]
[, rc0 null fast throw(string)]

by is allowed; see by

Description

capass is a simple wrapper for Stata's built-in assert command
that allows to throw error messages if the assertion evaluates to false. This is
especially useful if the assertion is hidden in quietly executed parts of the
code or in preserved mode.

Options

throw specifies the error message to be shown if the assertion evaluates
to false.

The remaining options are just like assert's options, so here is
what the built-in Stata Help has to say about their use:

rc0 forces a return code of 0, even if the assertion is false.

null forces a return code of 8 on null assertions.

fast forces the command to exit at the first occurrence that
exp evaluates to false.

Example

Instead of typing

. assert 1 + 1 == 3

assertion is false

r(9);

and wondering what the assertion was actually about, just type

. capass 1 + 1 == 3, throw("1 + 1 = 2. You should know this from elementary school...")

1 + 1 = 2. You should know this from elementary school...

assertion is false

r(9);

That's it.

Author

capass was written by Max Löffler (loeffler@zew.de),
Centre for European Economic Research (ZEW), Mannheim, Germany. Comments and
suggestions are welcome.

This command is no rocket science at all, so all credit goes to StataCorp for
their highly useful assert command. Thanks to Sebastian Siegloch
for inspiration.

License

Copyright (C) 2014, Max Löffler

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.