|
18 | 18 |
|
19 | 19 | __all__ = ['MagicRobot']
|
20 | 20 |
|
| 21 | +class MagicInjectError(ValueError): |
| 22 | + pass |
| 23 | + |
21 | 24 |
|
22 | 25 | class MagicRobot(wpilib.SampleRobot,
|
23 | 26 | metaclass=OrderedClass):
|
@@ -529,7 +532,7 @@ def _setup_vars(self, cname, component):
|
529 | 532 | # If the value given to the variable is an instance of a type and isn't a property
|
530 | 533 | # raise an error. No double declaring types, e.g foo: type = type
|
531 | 534 | if isinstance(attr, type) and not isinstance(attr, property):
|
532 |
| - raise ValueError("%s.%s has two type declarations" % (component_type.__name__, n)) |
| 535 | + raise MagicInjectError("%s.%s has two type declarations" % (component_type.__name__, n)) |
533 | 536 | # Otherwise, skip this set class variable
|
534 | 537 | continue
|
535 | 538 |
|
@@ -568,12 +571,12 @@ def _inject(self, n, inject_type, cname, component):
|
568 | 571 |
|
569 | 572 | # Raise error if injectable syntax used but no injectable was found.
|
570 | 573 | if injectable is None:
|
571 |
| - raise ValueError("Component %s has variable %s (type %s), which is not present in %s" % |
| 574 | + raise MagicInjectError("Component %s has variable %s (type %s), which is not present in %s" % |
572 | 575 | (cname, n, inject_type, self))
|
573 | 576 |
|
574 | 577 | # Raise error if injectable declared with type different than the initial type
|
575 | 578 | if not isinstance(injectable, inject_type):
|
576 |
| - raise ValueError("Component %s variable %s in %s are not the same types! (Got %s, expected %s)" % |
| 579 | + raise MagicInjectError("Component %s variable %s in %s are not the same types! (Got %s, expected %s)" % |
577 | 580 | (cname, n, self, type(injectable), inject_type))
|
578 | 581 | # Perform injection
|
579 | 582 | setattr(component, n, injectable)
|
|
0 commit comments