Go to:
Return value. Related commands. Flags. Examples.
Synopsis
error [flags] <string>
The error command is provided so that the user can issue
error messages from his/her scripts and
control execution in the event of runtime errors.
The string argument is displayed in the command window
(or stdout if running in batch mode) after
being prefixed with an error message heading and
surrounded by //.
The error command also causes execution to terminate with an error.
Using error is like raising an exception because the error will
propagate up through the call chain. You can use catch to
handle the error from the caller side. If you don't want
execution to end, then you probably want to use the warning
command instead.
Return value
None
Related commands
warningFlags
showLineNumber
| Long name (short name) | [argument types] | Properties |
|---|
-showLineNumber
(-sl)
| boolean | |
|
If true then file and line number information are displayed.
Default: false
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can be used more than once in a command
|
Examples
$l = `ls -lights`;
if (size($l) == 0) {
error "No Lights";
}
// The above will produce the following output and terminate execution
// of the script containing it:
// Error: No Lights //
$l = `ls -lights`;
if (size($l) == 0) {
error -showLineNumber true "No Lights";
}
// Adding "-showLineNumber true" to the same example will produce the
// following output and terminate execution of the script containing it:
// Error: line 3: No Lights //