-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
48 lines (38 loc) · 2.21 KB
/
Copy patherrors.py
File metadata and controls
48 lines (38 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Typed exceptions for the URDF parser.
Historically a malformed / unsupported URDF caused the parser to
``print(...)`` and call ``exit()`` -- a bare ``SystemExit`` that kills the
whole host process with no traceback and is uncatchable by normal
``except Exception`` handlers. These typed exceptions replace that failure
mode so callers (the equivalence harness, GRiD codegen, downstream tools)
can catch and surface a structured, debuggable error instead.
All parser-raised errors derive from :class:`URDFParseError` so a caller may
catch the whole family with a single ``except URDFParseError``.
"""
class URDFParseError(Exception):
"""Base class for every error raised while parsing a URDF model."""
class MimicResolutionError(URDFParseError, ValueError):
"""Raised when a ``<mimic>`` relation cannot be resolved (unknown target
joint or a mimic cycle). Derives from ValueError too so pre-existing
``except ValueError`` callers keep working, while the URDFParseError base
lets it propagate through ``parse()`` instead of degrading to None."""
class UnsupportedJointTypeError(URDFParseError):
"""Raised when a URDF joint declares a type the parser cannot model.
Carries the offending joint type (and optionally the joint name) so a
caller can report exactly which joint tripped the parser.
"""
def __init__(self, jtype, joint_name=None):
self.jtype = jtype
self.joint_name = joint_name
# Everything the parser models: revolute/continuous/prismatic/fixed/
# floating are Tier-A cardinal; helical (screw) parses natively;
# planar and translation DECOMPOSE at parse time into cardinal
# sub-joints; spherical parses as a native 3-DoF (NQ != NV) joint.
# RBDReference models all of these; downstream CUDA codegen gates any
# not-yet-ported algorithm with its own clear error.
supported = ("revolute, continuous, prismatic, fixed, floating, "
"helical (screw), planar, translation, spherical")
where = f" (joint '{joint_name}')" if joint_name is not None else ""
super().__init__(
f"Unsupported joint type '{jtype}'{where}. "
f"Supported joint types are: {supported}."
)