rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
Loading...
Searching...
No Matches
exceptions.py
Go to the documentation of this file.
1"""
2Copy of ROS2 `rclpy.exceptions` for ROS1.
3
4Supplemented copy from ROS2 `rclpy.exceptions`,
5at https://github.com/ros2/rclpy (`rclpy/rclpy/exceptions.py`),
6released under the Apache 2.0 License.
7
8------------------------------------------------------------------------------
9This file is part of rosros - simple unified interface to ROS1 / ROS2.
10Released under the BSD License.
11
12@author Erki Suurjaak
13@created 16.02.2022
14@modified 23.02.2022
15------------------------------------------------------------------------------
16"""
17## @namespace rosros.rclify.exceptions
18
19# Original file copyright notice:
20#
21# Copyright 2016 Open Source Robotics Foundation, Inc.
22#
23# Licensed under the Apache License, Version 2.0 (the "License");
24# you may not use this file except in compliance with the License.
25# You may obtain a copy of the License at
26#
27# http://www.apache.org/licenses/LICENSE-2.0
28#
29# Unless required by applicable law or agreed to in writing, software
30# distributed under the License is distributed on an "AS IS" BASIS,
31# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32# See the License for the specific language governing permissions and
33# limitations under the License.
34
35
37 """Raised when the rclpy implementation is accessed before rclpy.init()."""
38
39 def __init__(self, *args):
40 Exception.__init__(self, 'rclpy.init() has not been called', *args)
41
42
44 """Raised when there is no type support imported."""
45
46 def __init__(self, *args):
47 Exception.__init__(self, 'no type_support imported')
48
49
51 """Raised when a topic name, node name, or namespace are invalid."""
52
53 def __init__(self, name_type, name, error_msg, invalid_index, *args):
54 msg = """\
55Invalid {name_type}: {error_msg}:
56 '{name}'
57 {indent}^\
58""".format(name_type=name_type, name=name, error_msg=error_msg, indent=' ' * invalid_index)
59 Exception.__init__(self, msg)
60
61
63 """Raised when a namespace is invalid."""
64
65 def __init__(self, name, error_msg, invalid_index, *args):
66 NameValidationException.__init__(self, 'namespace', name, error_msg, invalid_index)
67
68
70 """Raised when a node name is invalid."""
71
72 def __init__(self, name, error_msg, invalid_index, *args):
73 NameValidationException.__init__(self, 'node name', name, error_msg, invalid_index)
74
75
77 """Raised when a topic name is invalid."""
78
79 def __init__(self, name, error_msg, invalid_index, *args):
80 NameValidationException.__init__(self, 'topic name', name, error_msg, invalid_index)
81
82
84 """Raised when a service name is invalid."""
85
86 def __init__(self, name, error_msg, invalid_index, *args):
87 NameValidationException.__init__(self, 'service name', name, error_msg, invalid_index)
88
89
91 """Base exception for parameter-related errors."""
92
93 def __init__(self, error_msg, parameters, *args):
94 Exception.__init__(self, f'{error_msg}: {parameters}')
95
96
98 """Raised when handling an undeclared parameter when it is not allowed."""
99
100 def __init__(self, parameters, *args):
101 Exception.__init__(self, 'Invalid access to undeclared parameter(s)', parameters, *args)
102
103
105 """Raised when declaring a parameter that had been declared before."""
106
107 def __init__(self, parameters, *args):
108 Exception.__init__(self, 'Parameter(s) already declared', parameters, *args)
109
110
112 """Raised when a parameter to be declared has an invalid name."""
113
114 def __init__(self, parameter, *args):
115 Exception.__init__(self, 'Invalid parameter name', parameter, *args)
116
117
119 """Raised when a parameter is rejected by a user callback or when applying a descriptor."""
120
121 def __init__(self, parameter, value, reason, *args):
122 Exception.__init__(
123 self,
124 'Invalid parameter value ({value}) for parameter. Reason: {reason}'.format(
125 value=value, reason=reason), parameter, *args)
126
127
129 """Raised when a read-only parameter is modified."""
130
131 def __init__(self, parameter, *args):
132 Exception.__init__(self, 'Attempted to modify read-only parameter', parameter, *args)
133
134
136 """Raised when an operation is canceled by rclpy shutting down."""
137
138 def __init__(self, *args):
139 Exception.__init__(self, 'rclpy.shutdown() has been called', *args)
Raised when a namespace is invalid.
Definition exceptions.py:62
__init__(self, name, error_msg, invalid_index, *args)
Definition exceptions.py:65
Raised when a node name is invalid.
Definition exceptions.py:69
__init__(self, name, error_msg, invalid_index, *args)
Definition exceptions.py:72
Raised when a parameter to be declared has an invalid name.
Raised when a parameter is rejected by a user callback or when applying a descriptor.
__init__(self, parameter, value, reason, *args)
Raised when a service name is invalid.
Definition exceptions.py:83
__init__(self, name, error_msg, invalid_index, *args)
Definition exceptions.py:86
Raised when a topic name is invalid.
Definition exceptions.py:76
__init__(self, name, error_msg, invalid_index, *args)
Definition exceptions.py:79
Raised when a topic name, node name, or namespace are invalid.
Definition exceptions.py:50
__init__(self, name_type, name, error_msg, invalid_index, *args)
Definition exceptions.py:53
Raised when there is no type support imported.
Definition exceptions.py:43
Raised when the rclpy implementation is accessed before rclpy.init().
Definition exceptions.py:36
Raised when declaring a parameter that had been declared before.
Base exception for parameter-related errors.
Definition exceptions.py:90
__init__(self, error_msg, parameters, *args)
Definition exceptions.py:93
Raised when a read-only parameter is modified.
Raised when handling an undeclared parameter when it is not allowed.
Definition exceptions.py:97
Raised when an operation is canceled by rclpy shutting down.