Errors¶
This page covers the errors you raise from inside a node: which one to reach for, where each one travels once it leaves your hook, how retries work, and how to add an error type of your own. After reading it you can pick the right error for a failure, know which of its fields survive the trip, and give whoever is on the other end enough to act on.
The NodeError vocabulary on this page is new in 2.42.0; the Mock Runner and the node template ship SDK 2.46.2, which has all of it. A project pinned to an older SDK keeps raising NodeExecutionError and NodeConfigurationError, as the tutorials still do; nothing in the older family is being removed.
Since SDK 2.48.0
C++ nodes have the same vocabulary in <neuraverse_sdk/utils/NodeErrors.hpp>. See Typed errors for the differences.
Raise a typed error¶
Import the error, pick the factory that describes what happened, raise it:
from neuraverse_sdk.models.errors import NodeDataError
raise NodeDataError.invalid(f"speed must be > 0, got {speed}")
Your node runs as a gRPC server, and the engine that drives your graph calls it to configure, pause, stop and check its health. When you raise from one of those hooks the exception becomes that call's response, built by the SDK's error boundary. The boundary reads a gRPC status off your error, here INVALID_ARGUMENT because you chose NodeDataError.invalid, and a safe message, here the factory's default "Provided data is invalid."
on_execute is the exception, and it is worth knowing before you write your first raise site. Nothing is waiting on a response there: a run is started by a trigger arriving on the transport, or by a RunNode call that returns as soon as the run is queued. An error raised from on_execute therefore never becomes a gRPC response.
| Where you raise | How the failure travels | What the vocabulary buys you |
|---|---|---|
on_configure, on_stop, on_pause, on_resume, on_health_check, on_toggle_simulation_mode, on_get_configuration |
The gRPC response for that engine call, through the error boundary | An accurate status, a safe message, error codes on a public error, retry advice |
on_execute |
The node log, the ERROR state on the status stream, and the Error trigger output when your schema declares one |
An accurate err_type for a downstream handler, and the right class for your own except blocks |
The Error trigger is not scrubbed
The boundary is what drops a private message, and an on_execute failure never reaches it. The Error trigger carries err_type and err_msg filled straight from the exception, so your developer message reaches the downstream nodes in the same graph verbatim. This is how the SDK has always behaved and the vocabulary does not change it. Keep secrets out of the message on that path: a broker URL or a device register is fine, a credential never was.
Everything below about public and private applies to the first row. The second row is covered in Lifecycle and states and Triggers.
Three classes, picked by cause¶
Ask whose fault the failure is:
| Class | Use when | Raise it for |
|---|---|---|
NodeDataError |
The input is at fault | Missing config, malformed payload, out-of-range value |
NodeDependencyError |
Something the node talks to is at fault | Robot, gripper, camera, AI model, external service |
NodeError |
The node itself is at fault | Broken invariant, unreachable branch, unsupported request |
NodeDataError and NodeDependencyError both extend NodeError, so except NodeError catches the whole family.
Always construct through a factory rather than the bare class. The factory attaches the error code, and the code is what fixes the caller's status and lets calling code branch on the failure. Raise NodeDataError("...") directly and you get an error with no code and no safe message: the status falls back to the class default and the caller sees only a generic transaction-id message.
NodeDataError: The data a node was asked to work with is unusable.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
NodeDataError.invalid(msg) |
err.node.data.invalid |
INVALID_ARGUMENT |
Input arrived but is wrong - bad type, wrong shape, out-of-range value. | Provided data is invalid. |
NodeDataError.missing(msg) |
err.node.data.missing |
INVALID_ARGUMENT |
A required input or field was not supplied at all. | Required data is missing. |
NodeDataError.unprocessable(msg) |
err.node.data.unprocessable |
INVALID_ARGUMENT |
Input is well formed and in range, but the node cannot act on it here. | Provided data could not be processed. |
NodeDependencyError: Something the node depends on failed it - robot, gripper, camera, AI model.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
NodeDependencyError.unavailable(msg) |
err.node.dependency.unavailable |
UNAVAILABLE |
A dependency cannot be reached at all - not connected, not running, not found. | A required dependency is currently unavailable. |
NodeDependencyError.busy(msg) |
err.node.dependency.busy |
RESOURCE_EXHAUSTED |
A dependency is reachable but refused the work because it is saturated. | A required dependency is busy. Retrying may help. |
NodeDependencyError.timeout(msg) |
err.node.dependency.timeout |
DEADLINE_EXCEEDED |
A dependency accepted the request but did not answer within the deadline. | A dependency did not respond in time. |
NodeDependencyError.failure(msg) |
err.node.dependency.failure |
UNAVAILABLE |
A dependency answered, and the answer was an error. | A dependency operation failed. |
NodeError: Base class for errors raised by node implementations.
| Factory | Error code | gRPC status | Raise it when | Caller sees by default |
|---|---|---|---|---|
NodeError.unknown(msg) |
err.node.unknown |
INTERNAL |
A node failure that fits none of the specific categories. | An unexpected error occurred in the node. |
NodeError.fault(msg) |
err.node.fault |
INTERNAL |
The node cannot do its job and the cause is the node itself. | The node could not complete this operation. |
When no code is attached the status comes from the class instead: NodeDataError gives INVALID_ARGUMENT, NodeDependencyError and NodeError both give INTERNAL.
fault() and unknown() take their status from the class
Their codes are not in the status table, so the INTERNAL above holds only when you call them on NodeError itself. NodeDataError.fault(...) resolves to INVALID_ARGUMENT from its class, which is not what "the node is at fault" means. Call them on NodeError.
Picking between near neighbours¶
invalidagainstunprocessable. Context. A point cloud with no overlapping frames is valid data that this node still cannot process.unavailableagainstbusy. Is it answering?busymeans alive and pushing back,unavailablemeans nothing is there.failureagainst the specific three.failureis the catch-all. Reach fortimeout,busyorunavailablewhenever you know which happened, because each gives the caller a different status.faultagainstunknown. Usefaultwhen your own logic is at fault.unknownis the last resort.
A node with three raise sites¶
GripperNode validates its configuration, validates its input and wraps a hardware failure, each with a different error:
class GripperNode(NodeBase):
"""Closes a gripper to the width arriving on ``target_width_mm``."""
def on_configure(
self,
config: ScalarMap[str, str],
dynamic_config: MessageMap[str, NodeConfigEntry] | None = None,
) -> None:
"""Connects to the gripper named in the static configuration."""
self._host = config.get("gripper_host")
if not self._host:
# A required setting was never filled in: the request is at fault.
raise NodeDataError.missing("config key 'gripper_host' is not set")
self._gripper = FakeGripper(self._host)
def on_execute(self, trigger_context: Optional[TriggerContext] = None) -> None:
"""Validates the requested width, drives the gripper, publishes the result."""
msg = self.get_data("target_width_mm")
if msg is None:
# Nothing arrived on the input port.
raise NodeDataError.missing("no data on input port 'target_width_mm'")
width = msg.data
if not MIN_WIDTH_MM < width <= MAX_WIDTH_MM:
# Something arrived, but the node cannot act on it. The message is
# about the graph's own data, so it is safe to publish as-is.
raise NodeDataError.invalid(
f"target_width_mm must be in ({MIN_WIDTH_MM}, {MAX_WIDTH_MM}], got {width}"
).as_public()
try:
result = self._gripper.grasp(width, timeout_s=5)
except GripperTimeout as exc:
# The hardware is at fault, and it may well work on the next attempt.
raise (
NodeDependencyError.timeout(
f"gripper at {self._host} did not ack grasp within 5s: {exc}"
)
.retryable()
.with_retry_hint_min_wait_ms(500)
) from exc
self.publish("grasp_result", String(data=result))
Three things to copy from it:
- Check for
Nonebefore you use an input.get_data()returnsNonewhen nothing arrived. Without that guard the comparison raisesTypeError, which reaches the caller as anINTERNALwith your message replaced by a generic one. - Name the host and the vendor exception in the message. None of it leaves the process.
- Use
from excwhen you wrap a third-party exception, so the original traceback survives in the log.
If you raise something else¶
A plain ValueError, a KeyError or any exception from a vendor library does not go through the node-error path. It is logged, then reduced to a generic INTERNAL whose message names only the transaction id, with no code, no status distinction and no retry advice. Catch and translate at the point where you know what went wrong:
try:
frames = self._camera.capture()
except VendorCameraError as exc:
raise NodeDependencyError.failure(f"capture failed on {self._host}: {exc}") from exc
Errors from the Neuraverse libraries that are already public, for example NeuraPublicValidationError, are the exception: they keep their own status and message.
What the caller receives¶
This section is about the engine calls in the first row of the table above. Every node error is private by default. A private error is written to the log in full, then reduced before it goes on the wire:
graph TD
R["raise NodeDependencyError.timeout(...)"] --> V{"private or public?"}
V -->|"private, the default"| L["logged in full"]
L --> P["caller receives:<br/>status<br/>safe message<br/>retry flag and hint"]
V -->|"you called .as_public()"| W["caller receives:<br/>status<br/>your message<br/>retry flag and hint<br/>error codes<br/>labels"]
Three consequences to plan around:
Write the developer message freely. Name a vendor library, a filesystem path, a device register, a broker URL. A private error's message is logged and then dropped, so none of it reaches the engine. The one place it still travels is the Error trigger out of on_execute, as the warning above says.
The status is accurate either way. It comes from your error code or your class, never from your prose, so the caller can always branch on it. Error codes, by contrast, only reach the caller on a public error. Do not build a caller around codes unless the error is public.
The detail is findable. The log line carries a transaction id, and the same id travels back to the caller in the response metadata. When your error has no safe message at all the caller's message becomes "An error occurred while processing. See logs (transactionId: ...)."
Call .as_public() when you have read the message and know it carries no internal detail. The message then reaches the caller verbatim, codes and labels included:
# Every word here is yours, about the graph's own data, so nothing internal leaks.
raise NodeDataError.invalid(f"target_width_mm must be in (0, 80], got {width}").as_public()
The fields an error carries¶
Only message is required. A factory fills in error_codes and the default user message for you.
| Field | Set it with | Survives a private error? |
|---|---|---|
message |
the factory or constructor argument | No. Logged, then dropped |
messages_by_audience |
with_user_message() |
Yes, as the caller's message |
error_codes |
with_errorcode() |
No |
is_retryable |
retryable() |
Yes |
retry_hint_min_wait_ms |
with_retry_hint_min_wait_ms() |
Yes |
labels |
with_label() / with_labels() |
No |
message is the developer-facing detail and the only place the full story survives. Name the value, the limit, the host, the vendor exception.
messages_by_audience is the safe caller-facing text, and the one field that carries your words across a private boundary. Every factory sets a default; override it when you can say something more useful:
raise NodeDataError.invalid(f"target_width_mm {width} outside (0, 80]").with_user_message(
"Target width must be between 0 and 8 cm."
)
Write user messages out in full
A private error's labels are dropped, so {placeholders} in a user message are not resolved and the caller would see the literal braces. Use placeholders only on an error you have made public.
with_audience_message() accepts other audiences, but a private error forwards only the user one and drops the rest silently.
error_codes are stable strings that let a caller write an if instead of matching on prose. The factory attaches the right one, so you rarely set this by hand. When an error carries several codes the most specific status wins, not the worst: an error marked both busy and timeout reports RESOURCE_EXHAUSTED.
labels are key-value context for the log line, so a failure stays searchable without parsing prose:
raise NodeDependencyError.failure("grasp command rejected").with_labels({
"gripper_host": self._host,
"firmware": self._gripper.firmware,
"command": "0x2F",
})
Labels are dropped from a private error, so treat them as log material unless you have made the error public.
The chain is a builder¶
Factories return the error and so does every with_* method, so you can keep going:
raise (
NodeDataError.unprocessable("point cloud has no overlapping frames")
.with_label("frame_count", len(frames))
.with_user_message("The scan could not be processed: frames do not overlap.")
.as_public()
)
Retrying¶
is_retryable is a flag, not a type. auto_retry acts on the flag alone, so you decide which of your failures are worth a second attempt. Mark it when the dependency is alive but not ready, typically busy or timeout. Leave it unset when the input is wrong or the dependency is gone, because retrying changes nothing there.
@auto_retry(max_attempts=3)
def _read_firmware(self) -> str:
"""Reads the firmware version, retrying while the gripper is saturated."""
if self._gripper.busy:
raise (
NodeDependencyError.busy("gripper rejected the read, command queue full")
.retryable()
.with_retry_hint_min_wait_ms(200)
)
return self._gripper.firmware
max_attempts is the total number of attempts, not the number of retries. Once they run out auto_retry reraises your original error, so the caller sees the same code and message they would have seen on the first failure.
retry_hint_min_wait_ms is advice, and who takes it¶
The hint is never binding. It says "wait at least this long before trying again", and who honours it depends on who is retrying:
| Who retries | How it treats the hint |
|---|---|
auto_retry with the default wait strategy |
Waits exactly the hint. An error that never set one waits 0, so the attempts run back to back |
auto_retry with a wait strategy you pass |
Ignores the hint entirely and uses your strategy |
| The engine, after the error reaches it | Non-binding advice; it may wait longer, shorter, or not retry at all |
So there is no rule that every .retryable() needs a hint. Set one when the wait is part of what makes the retry work, and the default strategy is what will be doing the waiting: a device that needs two seconds to clear its queue, a rate limit that resets on a known interval, a controller that rejects commands while it homes. Leave it unset when an immediate second attempt is genuinely the right behaviour, for example a lost packet on a local link, or when you are passing your own wait strategy anyway:
from tenacity import wait_exponential
@auto_retry(max_attempts=4, wait=wait_exponential(max=10))
def _read_sensor(self):
...
The one case worth checking before you merge is a .retryable() with no hint, the default strategy, and a remote dependency: that combination sends three attempts at the dependency with no pause between them.
Your own error types¶
Subclass when your node family has a failure mode the built-in factories cannot name and callers need to tell it apart from its neighbours: a domain failure your downstream nodes react to programmatically, or a cluster of related codes that belong together, like calibration or safety interlocks. If you would only be renaming timeout, use timeout.
Extend the class whose cause matches yours, declare your codes as constants, and give each one a factory that mirrors the built-in shape:
class GripperError(NodeDependencyError):
"""Failures specific to the vendor gripper this node family drives."""
ERRCODE_NOT_CALIBRATED = "err.node.dependency.gripper.not_calibrated"
ERRCODE_JAMMED = "err.node.dependency.gripper.jammed"
@classmethod
def jammed(cls, msg: str):
"""Mechanical obstruction: the fingers did not reach the commanded width."""
return (
cls(msg)
.with_errorcode(cls.ERRCODE_JAMMED)
.with_user_message("The gripper is obstructed and could not close.")
)
Raise it exactly like a built-in, and you inherit the rest: private-by-default visibility, retryable(), as_public(), the builder methods and auto_retry compatibility.
Watch which status you land on¶
Your new codes are not in the status table, so the status falls back to your base class: NodeDataError gives INVALID_ARGUMENT, NodeDependencyError and NodeError both give INTERNAL. Extending NodeDependencyError therefore gives you INTERNAL, not UNAVAILABLE. To get a dependency-shaped status, attach a built-in code alongside your own:
@classmethod
def jammed(cls, msg: str):
"""Mechanical obstruction: the fingers did not reach the commanded width."""
return (
cls(msg)
.with_errorcode(cls.ERRCODE_JAMMED) # your code, for callers to branch on
.with_errorcode(cls.ERRCODE_FAILURE) # a known code, for the status
.with_user_message("The gripper is obstructed and could not close.")
)
The status now resolves to UNAVAILABLE from the known code. Both codes reach the caller only if the error is also made public.
Three conventions worth keeping: namespace your codes under the prefix you extend (err.node.dependency.<thing>.<problem>) so they sort and filter with the built-ins; set a user message on every factory, because it is the only field that carries your words past a private boundary; and docstring every factory, because those docstrings are the published reference.
Errors the SDK raises¶
Alongside the node errors sits a second family, SDKError, for failures in what the SDK manages on your behalf: transports, lifecycle transitions, platform services, configuration. These are the SDK's to raise, not yours. You never construct one, you catch it.
| Class | Covers | Status if no code matches |
|---|---|---|
SDKLifecycleError |
A lifecycle transition or mode change | INTERNAL |
SDKTransportError |
Publishing, subscribing or encoding on the data or control plane | INTERNAL |
SDKServiceError |
A platform service: Consul registration, digital twin, data repository, streaming | UNAVAILABLE |
SDKOperationError |
SDK housekeeping: bootstrap, status, health check, node lookup | INTERNAL |
SDKConfigError |
Configuration missing, invalid or unparseable | INVALID_ARGUMENT |
They are public by default, the reverse of NodeError. The SDK authored those messages, so the boundary passes them to the caller whole, error codes included. That default holds only while the message stays SDK-authored: SDK code that interpolates something external into one calls .as_private(), the mirror of the .as_public() you use on node errors.
Not raised by the SDK yet
The SDK's own internals still raise the older exceptions described below, so an except SDKTransportError block in your node will not fire in 2.42.0. Treat this section as the shape to expect rather than something to code against, and catch the older exceptions if you need to handle SDK failures today.
When the migration lands the handling pattern will be the familiar one: let the error propagate if it already says enough, or catch it and re-raise a NodeError that explains what your node was trying to do. Re-raising makes the detail private again, because the SDK message is public but the NodeError wrapping it is not, so set a with_user_message() if the caller needs to know what happened.
The older exceptions¶
Before 2.42.0 the SDK had one family, NodeSDKError in neuraverse_sdk.utils.exceptions, and the tutorials in this guide still use it. It is still supported and nothing is being removed, but it carries no error code, no public or private declaration and no retry advice, so a caller cannot tell a bad input from a dead device.
The SDK itself still raises it. DataFlowException on an unknown output port, TriggerFlowException on an unbound trigger type and NodeStateError on an illegal transition are all facts about the SDK you will keep seeing in this guide and in your logs.
What changes is which one you raise. New code should use the vocabulary on this page:
| Instead of raising | Raise |
|---|---|
NodeConfigurationError for a missing or unusable setting |
NodeDataError.missing() or NodeDataError.invalid() |
NodeExecutionError for bad or absent input |
NodeDataError.missing(), .invalid() or .unprocessable() |
NodeExecutionError for a device or service that failed |
NodeDependencyError.timeout(), .busy(), .unavailable() or .failure() |
NodeExecutionError for a bug or broken invariant in the node |
NodeError.fault() |
There is no migration deadline and no need for a big-bang change. The boundary handles both families side by side, so you can move one raise site at a time.
The full list of the older exceptions, with the base class and error_code of each:
| Exception | Base | error_code | Raised when |
|---|---|---|---|
DataFlowException |
NodeSDKError |
DATA_FLOW_ERROR |
Raised when dataflow is not valid |
InvalidEndpointError |
NodeSDKError |
ENDPOINT_NOT_FOUND |
Raised when an endpoint is not found |
NodeConfigurationError |
NodeSDKError |
CONFIG_ERROR |
Raised when there's an error in node configuration |
NodeExecutionError |
NodeSDKError |
EXECUTION_ERROR |
Raised when there's an error during node execution |
NodeHealthCheckError |
NodeSDKError |
HEALTH_CHECK_ERROR |
Raised when there's an error performing a health check |
NodeNotFoundError |
NodeSDKError |
NODE_NOT_FOUND |
Raised when a node is not found |
NodePauseError |
NodeSDKError |
PAUSE_ERROR |
Raised when there's an error during node pause |
NodeRegisteryError |
NodeSDKError |
NODE_REGISTRATION_ERROR |
Raised when a node is not able to register |
NodeResumeError |
NodeSDKError |
RESUME_ERROR |
Raised when there's an error during node resume |
NodeSDKError |
Exception |
Base exception for all Neuraverse SDK errors | |
NodeSimulationModeError |
NodeSDKError |
SIMULATION_MODE_ERROR |
Raised when there's an error toggling simulation mode |
NodeStateError |
NodeSDKError |
INVALID_STATE |
Raised when a node is in an invalid state for the requested operation |
NodeStopError |
NodeSDKError |
STOP_ERROR |
Raised when there's an error during node stop |
RobotException |
NodeSDKError |
ROBOT_ERROR |
Raised when robot is in error |
TriggerFlowException |
NodeSDKError |
TRIGGER_FLOW_ERROR |
Raised when trigger flow is not valid |
Where to next¶
- Lifecycle and states for what an uncaught error does to the node's state and the
Errortrigger. - Triggers for reacting to an upstream node's failure with
is_triggered_by_error(). - Configuration for validating settings in
on_configure. - Errors reference on the SDK documentation site for the class-by-class listing rendered from the source.