ASCOM Alpaca Exception Classes

These exception classes are defined in the Alpaca API Reference and ASCOM Master Interfaces (Alpaca and COM) on the ASCOM main web site.

Exception Characteristics

When these ASCOM Alpaca specific exceptions are raised by the device, the internal logic reconstructs them as Python exceptions from the incoming device response JSON. Thus you get the same exceptions by name and value as defined in the ASCOM API.

Internal Arguments

It’s common to access the message of a built-in Python exception as provided by catch ex: as an ex.args array. These custom exceptions define ex.args[0] as the error number and ex.args[1] as the error message.

Properties

The exceptions not only have number and message attributes like built-in Python exception objects, but they also have number and message properties. Within an exception as provided by a catch ex: you can get the error number as ex.number and the error message as ex.message.

String Conversion

Like built-in Python exceptions, you can print out the exception parts via str(ex) which produces a string with the the error message then the error number in parentheses. For example, a DriverException with code 0x506:

Datalink connect failure (Error Code: 0x506)

As usual you can get the exception name via type(ex).__name__.

Default Uncaught Exceptions

Like built-in Python exceptions, the console output for uncaught exceptions prints the name of the exception and its error number and message as formatted by str(ex), for example:

alpaca.exceptions.DriverException: Datalink connect failure (Error Code: 0x506)

Exception Definitions

exception alpaca.exceptions.ActionNotImplementedException(message: str)

Bases: Exception

Exception thrown by a device when it receives an unknown command through the Action method.

Properties:
  • number (int): Constant 0x040C (1036)

  • message (str): Text of the error message

exception alpaca.exceptions.AlpacaRequestException(number: int, message: str)

Bases: Exception

Raised by the device’s Alpaca server for unknown or illegal requests.

Properties:
  • number (int): The HTTP response code (4xx or 5xx)

  • message (str): The concatenation of the server’s response text and the URL.

exception alpaca.exceptions.DriverException(number: int, message: str)

Bases: Exception

Generic driver exception. See note below.

Properties:
  • number (int): Assigned by the device and will be a number from 0x500 - 0xFFF

  • message (str): Text of the error message

Note

This is the generic driver exception. Drivers are permitted to directly throw these exceptions. This exception should only be thrown if there is no other more appropriate exception as listed here are already defined. These specific exceptions should be thrown where appropriate rather than using the more generic DriverException. Conform will not accept DriverExceptions where more appropriate exceptionsare already defined.

exception alpaca.exceptions.InvalidOperationException(message: str)

Bases: Exception

Thrown by the device to reject a command from the client.

Properties:
  • number (int): Constant 0x40B (1035)

  • message (str): Text of the error message

exception alpaca.exceptions.InvalidValueException(message: str)

Bases: Exception

Exception to report an invalid value supplied to a device.

Properties:
  • number (int): Constant 0x401 (1025)

  • message(str): Text of the error message

exception alpaca.exceptions.NotConnectedException(message: str)

Bases: Exception

An operation is attempted that requires communication with the device, but the device is disconnected.

Properties:
  • number (int): Constant 0x407 (1031)

  • message(str): Text of the error message

This refers to the driver not being connected to the device. It is not for network outages or bad URLs.

exception alpaca.exceptions.NotImplementedException(message: str)

Bases: Exception

Property or method is not implemented in the device

Properties:
  • number (int): Constant 0x400 (1024)

  • message(str): Text of the error message

exception alpaca.exceptions.OperationCancelledException(message: str)

Bases: Exception

An (asynchronous) in-progress operation has been cancelled.

Properties:
  • number (int): Constant 0x40E (1038)

  • message(str): Text of the error message

exception alpaca.exceptions.ParkedException(message: str)

Bases: Exception

Movement (or other invalid operation) was attempted while the device was in a parked state.

Properties:
  • number (int): Constant 0x408 (1032)

  • message(str): Text of the error message

exception alpaca.exceptions.SlavedException(message: str)

Bases: Exception

Movement (or other invalid operation) was attempted while the device was in slaved mode. This applies primarily to Dome drivers.

Properties:
  • number (int): Constant 0x409 (1033)

  • message(str): Text of the error message

exception alpaca.exceptions.ValueNotSetException(message: str)

Bases: Exception

No value has yet been set for this property.

Properties:
  • number (int): Constant 0x402 (1026)

  • message(str): Text of the error message