Understanding Cli Scripting Errors - Oracle ZFS Storage Appliance Administration Manual

Hide thumbs Also See for ZFS Storage Appliance:
Table of Contents

Advertisement

Understanding CLI Scripting Errors

When an error is generated, an exception is thrown. The exception is generally an object that
contains the following members:
code - a numeric code associated with the error
message - a human-readable message associated with the error
Exceptions can be caught and handled, or they may be thrown out of the script environment. If
a script environment has an uncaught exception, the CLI will display the details. For example:
dory:> script run('not a cmd')
error: uncaught error exception (code EAKSH_BADCMD) in script: invalid command
"not a cmd" (encountered while attempting to run command "not a cmd")
You could see more details about the exception by catching it and dumping it out:
dory:> script try { run('not a cmd') } catch (err) { dump(err); }
{
toString: <function>,
code: 10004,
message: 'invalid command "not a cmd" (encountered while attempting to
run command "not a cmd")'
}
This also allows you to have rich error handling, for example:
#!/usr/bin/ksh -p
ssh -T root@dory <<EOF
script
try {
run('shares select default select $1');
} catch (err) {
if (err.code == EAKSH_ENTITY_BADSELECT) {
}
throw (err);
}
printf('"default/$1": compression is %s\n', get('compression'));
exit(0);
EOF
printf('error: "$1" is not a share in the ' +
'default project\n');
exit(1);
Using the Choices Function
About the Oracle ZFS Storage Appliance
53

Advertisement

Table of Contents
loading

Table of Contents