nidaqlib.errors¶
nidaqlib.errors ¶
Typed exception hierarchy for :mod:nidaqlib.
Every library exception inherits from :class:NIDaqError and carries a
structured :class:ErrorContext describing the failing operation. See design
doc §16.
ErrorContext
dataclass
¶
ErrorContext(
task_name=None,
channel_name=None,
physical_channel=None,
operation=None,
ni_error_code=None,
extra=_empty_extra(),
)
Structured context attached to every :class:NIDaqError.
Fields are best-effort — missing data is None rather than raising. The
DAQ-specific keys (task_name, physical_channel, ni_error_code)
let cross-instrument log readers join NIDaq exceptions to the same task /
channel / error-code identifiers visible from raw nidaqmx-python.
extra accepts any Mapping and is always frozen into a read-only
:class:types.MappingProxyType at construction so the shared empty
sentinel can never be mutated through error.context.extra[k] = v.
merged ¶
Return a new context with updates overlaid. Unknown keys go to extra.
Source code in src/nidaqlib/errors.py
NIDaqBackendError ¶
Bases: NIDaqError
The backend rejected an operation or surfaced a generic NI failure.
Used when the failure is not a clean fit for the more specific subclasses
(read, timeout, validation, state). Wraps :class:nidaqmx.errors.DaqError
via __cause__.
Source code in src/nidaqlib/errors.py
NIDaqConfigurationError ¶
Bases: NIDaqError
Configuration-level error (bad spec, missing required field, ...).
Source code in src/nidaqlib/errors.py
NIDaqConfirmationRequiredError ¶
Bases: NIDaqConfigurationError
A safety-gated start was attempted without confirm=True.
Raised by :func:open_device and :meth:DaqManager.start when a task
that drives hardware (counter pulse outputs, analog outputs) is started
without the explicit confirm=True opt-in. See design §5.10 (safe-start
gate) and the ecosystem ConfirmationRequiredError convention shared
with :mod:watlowlib and :mod:sartoriuslib.
Source code in src/nidaqlib/errors.py
NIDaqConnectionError ¶
Bases: NIDaqError
Communication with the NI backend was lost or could not be established.
Aligns with the ecosystem ConnectionError convention (matching
:class:watlowlib.WatlowConnectionError,
:class:alicatlib.AlicatConnectionError,
:class:sartoriuslib.SartoriusConnectionError). NI's backend rarely
distinguishes "connection lost" from generic backend errors at the
driver layer; this class is the family seam for those that do.
Source code in src/nidaqlib/errors.py
NIDaqDependencyError ¶
Bases: NIDaqError
A required dependency (driver, optional extra) is unavailable.
Source code in src/nidaqlib/errors.py
NIDaqError ¶
Bases: Exception
Base class for every :mod:nidaqlib exception.
Carries a typed :class:ErrorContext. The message is the human-readable
summary; the context is the machine-readable detail.
Initialise with a human-readable message and optional context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Short, human-readable summary suitable for logs. |
''
|
context
|
ErrorContext | None
|
Structured fields about the failing operation. |
None
|
Source code in src/nidaqlib/errors.py
with_context ¶
Return a copy of this error with its context updated.
Useful when an inner layer raises and an outer layer wants to enrich
the context (for instance adding task_name or operation).
Source code in src/nidaqlib/errors.py
NIDaqReadError ¶
Bases: NIDaqError
A read against the underlying NI task failed.
Source code in src/nidaqlib/errors.py
NIDaqResourceError ¶
Bases: NIDaqError
A physical-channel conflict was detected by the manager preflight.
Best-effort signal — NI is the final authority. Raised by
:meth:DaqManager.add when the new task's channels overlap with one
already managed; ErrorContext.extra carries the conflicting task names
under "conflicts".
Source code in src/nidaqlib/errors.py
NIDaqSinkDependencyError ¶
Bases: NIDaqSinkError
A sink's optional dependency (pyarrow, asyncpg, ...) is missing.
Source code in src/nidaqlib/errors.py
NIDaqSinkError ¶
Bases: NIDaqError
Base class for sink-layer failures.
Source code in src/nidaqlib/errors.py
NIDaqSinkSchemaError ¶
Bases: NIDaqSinkError
A sink rejected an input record's shape.
Most commonly raised by row-oriented sinks (CsvSink, JsonlSink)
when handed a :class:~nidaqlib.tasks.DaqBlock without
accept_blocks=True — silently scalarising would surprise users with
1-GB CSV files at 10 kHz × 8 channels (design doc §14.1).
Source code in src/nidaqlib/errors.py
NIDaqSinkWriteError ¶
Bases: NIDaqSinkError
A sink failed while writing a batch (file I/O, DB error, ...).
Source code in src/nidaqlib/errors.py
NIDaqTaskStateError ¶
Bases: NIDaqError
Operation invalid for the task's current lifecycle state.
Raised, for example, by :meth:DaqSession.poll when the task is buffered
and started — two consumers on the same NI buffer would race.
Source code in src/nidaqlib/errors.py
NIDaqTimeoutError ¶
Bases: NIDaqError
An NI read or write exceeded its configured timeout.
Source code in src/nidaqlib/errors.py
NIDaqValidationError ¶
Bases: NIDaqConfigurationError
Request validation failed before any I/O.
Source code in src/nidaqlib/errors.py
NIDaqWriteError ¶
Bases: NIDaqError
A write against the underlying NI task failed.
Raised by :meth:DaqSession.write when the backend rejects the write.
Out-of-range values fail earlier as :class:NIDaqValidationError.