Cows raises warnings and errors to handle special circumstances or programming errors. Sometimes, you may prefer to perform some checks on your own, and raise your own warnings and errors.
As an example, if a given script is intended to be included with two parameters, you can check for this condition and raise an error.
raiseerror (message
) raiseerror (message
,short_message
) raisewarning (message
) raisewarning (message
,short_message
)
Function raiseerror () raises an error message, while raisewarning () raises a warning. Both functions can take one or two parameters representing the message given to user. The optional short message is the one given if option (-brief is used).
Cows will automatically add informations related to file and line where the event occurred.
if (argc != 3) raisewarning ("Wrong Number Of Parameters";) if (style == "text") include ("text.cws"); elif (style == "std") include ("std.cws"); else raiseerror ("Only `text' and `std' styles supported");
First, we check if the script has been included with two parameters (remember that a parameter with file name is always passed so we have to check for three parameters). If the number of parameters is different, a warning is raised.
Then we include file text.cws or std.cws according to variable style
. If
the variable has an unexpected value, we raise an error.
This manual can be downloaded from http://www.g-cows.org/.