stoner_measurement.instruments.errors.InstrumentError

exception stoner_measurement.instruments.errors.InstrumentError(message: str, *, command: str | None = None, error_code: int | None = None)[source]

Raised when an instrument reports a command or execution error.

Carries structured information about the failure so that calling code can log or display a meaningful diagnostic without parsing the exception message string.

Variables:
  • command (str | None) – The command string that triggered the error, or None if the failing command is not known.

  • error_code (int | None) – Numeric error code returned by the instrument (e.g. the SCPI integer before the comma in a SYST:ERR? response), or None for protocols that do not use numeric codes.

  • message (str) – Human-readable description of the error as reported by the instrument.

Examples

>>> from stoner_measurement.instruments.errors import InstrumentError
>>> exc = InstrumentError(
...     "Undefined header",
...     command="*IDN",
...     error_code=-113,
... )
>>> exc.command
'*IDN'
>>> exc.error_code
-113
>>> str(exc)
'Undefined header (command: *IDN, code: -113)'