Microsoft Virtualization Discussions

how to refer to zapi error code by name

nthakur
4,547 Views

Get-NaControllerError prints all zapi error codes. If I want to compare the error code in my script, how do I refer to the error code by name? For example, $ErrorNumber -eq $EONTAP_EPERM instead of $ErrorNumber -eq 1.

PS C:\Toolkit\1.7.0> Get-NaControllerError

Code Name                    Description

---- ----                    -----------

    1 EONTAPI_EPERM           Operation not permitted

    2 EONTAPI_ENOENT          No such file or directory

    3 EONTAPI_ESRCH           No such process

    4 EONTAPI_EINTR           Interrupted system call

    5 EONTAPI_EIO             Input/Output error

Thanks,

neelesh

4 REPLIES 4

cknight
4,547 Views

Not sure I understand the question, but the cmdlet does accept arguments such as the name (which could be a variable):

PS C:\> Get-NaControllerError -Name EONTAPI_EPERM


Code Name                                     Description

---- ----                                     -----------

   1 EONTAPI_EPERM                            Operation not permitted

PS C:\> Get-NaControllerError -Code 1

Code Name                                     Description

---- ----                                     -----------

   1 EONTAPI_EPERM                            Operation not permitted

nthakur
4,547 Views

Thanks for the reply. I am looking for a way to use EONTAPI_* inside my script. Currently I have:

# at the top

$E_JOB_EXISTS = 18380

# somewhere down in the script

if ($errorNumber -eq $E_JOB_EXISTS)
{

Is there a better way to do this using a builtin EONTAPI_JOB_EXISTS variable?

Thanks.

cknight
4,548 Views

There aren't built-in variables for error codes, but you can do this:

if ($errorNumber -eq (Get-NaControllerError EONTAPI_EEXIST).Code) {...}

nthakur
4,548 Views

Ok. Thanks.

Public