Verified Commit 8076caf2 authored by Leon Mauritz Möller's avatar Leon Mauritz Möller
Browse files

adapter.xml: refactor helper functions and improve error handling

remove _unwrap() as it produced error messages that weren't helpful

add _get_text_mandatory_mapped() and _get_attrib_mandatory_mapped()
These are helper functions for retrieving an attribute or the text of
an xml element and then using the value as the key in a specified dict.
These are useful since they will raise a helpful error if
the attribute or text does not exist in the dict as a key.

add _get_child_mandatory() + _get_attribute_mandatory()
Functions for retrieving a mandatory child element or a mandatory attribute
and raising an error with a helpful message if the child/attribute doesn't exist.

_get_text_mandatory()'s signature is now similar to _get_child_mandatory()
and _get_attribute_mandatory(). It won't accept None anymore, and it now
also raises a KeyError instead of a TypeError.

change _failsafe_construct()
This function will now handle Key and Value errors.
It will now print the whole error cause chain.

change constructor functions depending on these helper functions respectively

add a check if type of last key matches reference type when constructing
AAS References
parent 4580bbc6
Pipeline #260663 passed with stage
in 3 minutes and 7 seconds
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment