Exceptions

When invoking SNAPconnect functions, your program should be prepared to “catch” any Python exceptions that are “thrown” (raised).

The following lists the possible Python exceptions that can be thrown by the SNAPconnect libraries and some possible causes (exception text messages).

Note

Obvious exceptions like Exception, KeyboardInterrupt, and SystemExit are not shown.

Thrown by apy

The monotime module in the apy package can throw the following exception:
  • OSError
The PostThread module in the apy package can throw the following exception:
  • RuntimeError

Thrown by serialwrapper

The ComUtil module in the serialwrapper package can throw the following exceptions:
  • NoMorePortsError
    • “No more ports to scan”
  • Exception
    • “Did not receive expected response”
    • “Unknown probe version”
The ftd2xxserialutil module in the serialwrapper package can throw the following exceptions:
  • Ftd2xxSerialException
    • “Cannot set number of devices”
  • ValueError
    • “Serial port MUST have enabled timeout for this function!”
    • “Not a valid port: …”
    • “Not a valid baudrate: …”
    • “Not a valid byte size: …”
    • “Not a valid parity: …”
    • “Not a valid stopbit size: …”
    • “Not a valid timeout: …”
The ftd2xxserialwin32 module in the serialwrapper package can throw the following exceptions:
  • Ftd2xxSerialException
    • “Port must be configured before it can be used”
    • “Could not find devices to open: …”
    • “Could not find port: …”
    • “Could not open device: …”
    • “Could not set latency: …”
    • “Can only operate on an open port”
    • “Could not set timeouts: …”
    • “Could not set baudrate: …”
    • “Could not set break: …”
    • “Could not reset break: …”
    • “Could not get CTS state: …”
    • “Could not get DSR state: …”
    • “Could not get RI state: …”
    • “Could not get DCD state: …”
    • “Could not set stopbits, parity, and/or bits per word: …”
    • “Could not set flow control: …”
    • “Cannot configure port, some setting was wrong…”
    • “An error occurred while checking rx queue: …”
    • “An error occurred while reading: …”
    • “An error occurred while writing: …”
    • “An error occurred while flushing the input buffer: …”
    • “An error occurred while setting RTS: …”
    • “An error occurred while clearing RTS: …”
The PyserialDriver module in the serialwrapper package can throw the following exceptions:
  • Exception
    • “Buffers don’t match”
  • Serial.SerialException
    • “WriteFile failed…”
    • “write failed: …”
  • PortNotOpenError
  • TypeError
    • “Expected str or bytearray, got …”
    • “Unknown serial driver type”
    • “Unsupported output type”
  • SerialOpenException
    • “SNAP USB devices are not currently supported on this platform”
    • “An error occurred while setting up the serial port: …”
The usbxserialutil module in the serialwrapper package can throw the following exceptions:
  • ValueError
    • “Serial port MUST have enabled timeout for this function!”
    • “Not a valid port: …”
    • “Not a valid baudrate: …”
    • “Not a valid byte size: …”
    • “Not a valid parity: …”
    • “Not a valid stopbit size: …”
    • “Not a valid timeout: …”
  • UsbxSerialException
    • “Cannot set number of devices”
The usbxserialwin32 module in the serialwrapper package can throw the following exceptions:
  • portNotOpenError
  • UsbxSerialException
    • “Port must be configured before it can be used”
    • “Unable to verify device PID: …”
    • “USB device was not found to be a SNAP USB device”
    • “Could not open device: …”
    • “Can only operate on an open port”
    • “Could not set timeouts: …”
    • “Could not set baud rate: …”
    • “Could not set stop bits, parity, and/or bits per word: …”
    • “Could not set flow control: …”
    • “Cannot configure port, some setting was wrong: …”
    • “Could not get CTS state…”
    • “An error occurred while checking rx queue: …”
    • “An error occurred while reading: …”
    • “Write time out occurred and there are no USB devices”
    • “A system error occurred while writing: …”
    • “An error occurred while flushing the input buffer: …”
    • “An error occurred while flushing the output buffer: …”

Thrown by snapconnect

The auth_digest module in the snapconnect package can throw the following exceptions:
  • cherrypy.HTTPError
    • “Bad Request…”
    • “You are not authorized to access that resource”
  • ValueError
    • “Authorization scheme is not Digest”
    • “Unsupported value for algorithm…”
    • “Not all required parameters are present”
    • “Unsupported value for qop: …”
    • “If qop is sent then cnonce and nc MUST be present”
    • “If qop is not sent, neither cnonce nor nc can be present”
    • “Unrecognized value for qop: …”
The dispatchers module in the snapconnect package can throw the following exception:
  • TypeError
    • “Unknown descriptor type”
The LicenseManager module in the snapconnect package can throw the following exception:
  • LicenseError
    • “… license file has expired”
    • “Your license is invalid…”
    • “Unable to load license file…”
The listeners module in the snapconnect package can throw the following exception:
  • ValueError
    • “Unknown serial type”
The snap module in the snapconnect package can throw the following exceptions:
  • ImportError
    • “Unable to find PyCrypto library required for AES support”
  • IOError
    • “Unable to load NV params file: …”
  • RuntimeError
    • “Non-licensed address provided”
    • “Invalid license found”
    • “Unable to determine callable functions”
    • “Tornado ioloop not supported”
    • “You must be accepting TCP connections to call accept_sniffer()”
  • TypeError
    • “Unknown Hook Type”
    • “Invalid callback”
    • “Invalid connection parameter provided”
  • ValueError
    • “Unknown encryption type specified: …”
    • “auth_info is not callable”
    • “Serial interface type must be an integer”
    • “Unsupported serial interface type”
The snaptcp module in the snapconnect package can throw the following exceptions:
  • socket.error
    • “Did not receive a valid lookup result”
  • ValueError
    • “SSL support was not found”

Thrown by snaplib

The DataModeCodec module in the snaplib package can throw the following exception:
  • DataModeEncodeError
    • “Packet is greater than 255 bytes”
    • “The packet is too large to encode …”
The MeshCodec module in the snaplib package can throw the following exception:
  • MeshError
    • “encode function does not yet support message type …”
    • “Packet is greater than 255 bytes”
    • “Mesh Routing message too large to encode …”
The RpcCodec module in the snaplib package can throw the following exceptions:
  • RpcError
    • “Do not receive a list of arguments”
    • “Source Address must be 3 bytes”
    • “Source Address must be between xFFxFFxFF and x00x00x00”
    • “No source address was set”
    • “No destination address/group was set”
    • “dmcast_dstAddrs length must be a multiple of 3 (including 0)”
    • “Original TTL for multicast must be greater than 0 and less than 256”
    • “Delay Factor for directed multicast must be between 0 and 255”
    • “The multicast group must be 2 bytes”
    • “Destination multicast group cannot be all zeros”
    • “TTL for multicast must be greater than 0 and less than 256”
    • “Packet cannot be a Directed Multicast without being a Multicast Packet first”
    • “The destination address must be 3 bytes”
    • “Int out of range”
    • “Function name cannot be None”
    • “Max string length is 255”
    • “Unsupported DataType: …”
    • “Packet is greater than 255 bytes”
    • “Function/Args too large to encode …”
  • TypeError
    • “Unsupported type …”
    • “String length is greater than 255”
    • “Integer is out of range”
  • WrongArgCount
The SnappyUploader module in the snaplib package can throw the following exception:
  • AlreadyInProgressError
    • “There is currently a SNAPpy upload already in progress”
The TraceRouteCodec module in the snaplib package can throw the following exception:
  • TraceRouteEncodeError
    • “The data is too large to encode”
    • “Packet is greater than 255 bytes”