Skip to main content

Errors and timeouts

Every SDK reports the same failures under the same names, so a test bench can handle them the same way in any language. The exceptions are the argument checks listed under Errors that are not a ScanaStudioError, which use each language's own exception types.

The taxonomy​

MeaningPython / NodeJSRustC
Base type for all of themScanaStudioErrorError—
The connection went awayConnectionClosedError::Closedss_status_Disconnected
The server refused the commandProtocolError (with code)Error::Protocolss_status_Refused
Nothing answered in timeTimeoutError::Timeoutss_status_Timeout
The server speaks another protocolVersionMismatchError::VersionNULL from ss_server_connect
The server refused to start the acquisition, with its written reasonRefusedError::Refusedss_status_Refused
The acquisition started, then ended in errorCaptureFailedError::CaptureFailedss_status_Failed
The workspace is frozen by an exportBusyError::Busyss_status_Refused
A script failed or rejected its configScriptError (with logs)Error::Scriptss_status_Failed
A file operation failedIoErrorError::Ioss_status_Failed
An option the script does not knowUnknownOption (with known)Error::UnknownOptionss_status_Failed
A script-library operation failedScriptOpError (with skipped, failed)Error::Ioss_status_Failed
A message could not be encoded or decoded as JSON—Error::Encodingss_status_Failed
The socket itself failed, or nothing listens at the URL—Error::SocketNULL from ss_server_connect
A NULL handle, a NULL or non-UTF-8 string, or request JSON that does not parse——ss_status_BadArgument
from ikalogic_scanastudio import (
CaptureFailed, ScanaStudio, ScanaStudioError, Refused, ScriptError, Timeout,
VersionMismatch,
)

try:
with ScanaStudio.connect() as server:
workspace = server.create("hw:1004250000604")
workspace.capture.run(samples=1_000_000, sample_rate=1_000_000_000)
except VersionMismatch as exc:
print(f"server speaks protocol {exc.spoken}, this SDK speaks {exc.supported}")
except Refused as exc:
print(f"the server would not start the capture: {exc}")
except CaptureFailed as exc:
print(f"the capture started, then failed: {exc}")
except ScriptError as exc:
print(exc)
for line in exc.logs: # the script's own output
print(" ", line)
except Timeout:
print("no answer in time")
except ScanaStudioError as exc:
print(f"something else went wrong: {exc}")

Errors that are not a ScanaStudioError​

Some arguments are checked by the SDK before anything is sent. Those checks raise the language's own exceptions, so an except ScanaStudioError or instanceof ScanaStudioError does not catch them:

CheckPythonNodeJS
A trigger built with a position outside 0 to 0.9, or an invalid mode, polarity or sequence orderValueErrorRangeError
A measurement name outside the 18 kindsValueErrorRangeError
An export source that is not samples, raw, packets or hexValueErrorRangeError
workspace.channel() with a name the device does not haveKeyErrorRangeError
An option value of the wrong type, such as None for a channelTypeErrorTypeError
An option value out of range: not a number, an unknown combo entry, an index past the endValueErrorRangeError
An option key the script does not declareUnknownOption, a subclass of KeyErrorUnknownOption, a ScanaStudioError

In Rust the same checks are either enforced by the types (MeasureKind, Mode) or returned as an Error: an unknown channel name is an Error::Protocol with the code no_such_channel.

Protocol error codes​

When the server refuses a command outright it sends a stable code, meant to be matched on rather than parsed out of the message:

CodeMeaning
bad_messageThe command was unreadable, or names a command that does not exist. Usually an SDK/server version mismatch. An add_measure naming an unknown measurement is refused whole with this code.
no_workspaceThe command needs a workspace and this connection is not attached to one.
generationA generation row could not be filled (generation.fill()). The message says why.

Not every failure is a protocol error. A capture the server will not start arrives as Refused, and an operation that started and then failed reports through its own error: CaptureFailed, IoError, ScriptError.

Timeouts​

Every blocking call takes a timeout, and the defaults differ because the operations do:

OperationDefault
Any single request/answer30 s
Creating or attaching a workspace60 s
Waiting for a capture (wait(), run())300 s
run() waiting for the capture to startthe timeout, at most 30 s
Waiting for decoding300 s
Waiting for measurements60 s
events.wait_for60 s
A script's GUI, decoders.add, pattern.add60 s
pattern.preview, scripts.sync, generation builders300 s
scripts.online120 s
Other script-library operations180 s
Save, open, export600 s

Python counts seconds as a float. NodeJS counts milliseconds, in a parameter named timeout_ms. Rust takes a std::time::Duration. C takes seconds as a double.

A timeout does not cancel the work

Timing out means you stopped waiting. The capture is still running, the export is still writing. Decide explicitly whether to stop() or to wait again, and remember the workspace is still there on the server either way.

Long captures need a long timeout, or none

A datalogger capture that runs for hours will exceed the 300 s default. Do not raise the timeout to match: start() without waiting, let the script exit, and come back later with attach(). See Headless datalogger.