Skip to content

Conversation

@mzagozen
Copy link
Contributor

NetconfError remains the main exception class, containing an optional summary message and a list of RpcError objects. A response may contain multiple rpc-error elements. RpcError encapsulates an individual rpc-error XML element with all RFC-defined fields parsed into typed attributes. It also preserves raw XML for optional vendor extensions.

Callback signatures were refined based on whether operations return data. Operations that only return ok or error (edit-config, commit, discard-changes, lock, unlock) use action(Client, ?NetconfError) while operations returning data (get, get-config, get-schema) use action(Client, ?xml.Node, ?NetconfError).

The generic rpc-reply handler now properly distinguishes between three response types: ok-only responses where ok must be the sole child element, error responses containing one or more rpc-error elements, and normal data responses. Empty rpc-reply elements are treated as errors since they violate the protocol specification.

Closes #33

@mzagozen
Copy link
Contributor Author

Ah, the test is failing because this also depends on the xml.Node improvements in stdlib.

NetconfError remains the main exception class, containing an optional
summary message and a list of RpcError objects. A response may contain
multiple rpc-error elements. RpcError encapsulates an individual
rpc-error XML element with all RFC-defined fields parsed into typed
attributes. It also preserves raw XML for optional vendor extensions.

Callback signatures were refined based on whether operations return
data. Operations that only return ok or error (edit-config, commit,
discard-changes, lock, unlock) use action(Client, ?NetconfError) while
operations returning data (get, get-config, get-schema) use
action(Client, ?xml.Node, ?NetconfError).

The generic rpc-reply handler now properly distinguishes between three
response types: ok-only responses where ok must be the sole child
element, error responses containing one or more rpc-error elements, and
normal data responses. Empty rpc-reply elements are treated as errors
since they violate the protocol specification.
@mzagozen mzagozen force-pushed the refactor-rpc-error branch from 3ff457b to d4a2943 Compare August 28, 2025 19:04
@mzagozen
Copy link
Contributor Author

I changed RpcError.__repr__() so that it doesn't include the entire XML.

@mzagozen mzagozen merged commit 1f4868b into main Aug 28, 2025
2 checks passed
@mzagozen mzagozen deleted the refactor-rpc-error branch August 28, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor RPC error handling

2 participants