NxLibException

class nxlib.exception.NxLibError(message=None)

This class represents an NxLib API error.

Parameters

message (str, optional) – The error message to be displayed. Defaults to None.

class nxlib.exception.NxLibException(path, error_code, command=None)

This class encapsulates NxLib API errors. All methods of NxLibItem and NxLibCommand not taking a return code pointer will throw an NxLibException when the API return code indicates an error.

It is possible to store the NxLibCommand object that caused the exception to keep temporary slots alive while an exception exists.

Parameters
  • path (str) – The path to the NxLibItem that caused the exception.

  • error_code (int) – The NxLib error code.

  • command (NxLibCommand, optional) – The command object that cause the exception. Defaults to None.

get_command_error_symbol()

The error symbol returned by the command execution.

Only available if the exception was thrown because execution of an NxLibCommand failed. You can check this using is_command_execution_failure(). If the node containing the error symbol does not exist the method will throw another NxLibException.

get_command_error_text()

The error text returned by the command execution.

Only available if the exception was thrown because execution of an NxLibCommand failed. You can check this using is_command_execution_failure(). If the node containing the error symbol does not exist the method will throw another NxLibException.

get_error_code()

Retrieves the API return code that has caused this exception.

Returns

The error code because of which the exception was raised.

Return type

int

get_error_text()

Retrieves the error text, corresponding to the API return code that has caused this exception. This is the error text return by nxlib.api.translate_error_code().

Returns

The text corresponding to the error code.

Return type

int

get_item_path()

Retrieves the path of the item that was attempted to access when the exception was raised.

Returns

The path of the item that has caused the exception.

Return type

str

is_command_execution_failure()

Whether this exception results from the failed execution of an NxLibCommand.

Exceptions resulting from failed command execution can have more information than those generated purely from C-API error codes: an additional error symbol (get_command_error_symbol()) and error text (getCommandErrorText()) that were returned by the command and describe the error in more detail.

Returns

True if this exceptions results from the failed

execution of an NxLibCommand.

Return type

bool