rmw  beta1
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
error_handling.h
Go to the documentation of this file.
1 // Copyright 2014 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RMW__ERROR_HANDLING_H_
16 #define RMW__ERROR_HANDLING_H_
17 
18 #if __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <stdbool.h>
24 #include <stddef.h>
25 
26 #include "rmw/macros.h"
27 #include "rmw/visibility_control.h"
28 
30 typedef struct rmw_error_state_t
31 {
32  const char * message;
33  const char * file;
34  size_t line_number;
36 
38 
54 void
55 rmw_set_error_state(const char * error_msg, const char * file, size_t line_number);
56 
58 
67 #define RMW_SET_ERROR_MSG(msg) rmw_set_error_state(msg, __FILE__, __LINE__);
68 
71 bool
72 rmw_error_is_set(void);
73 
75 
84 const rmw_error_state_t *
86 
88 
95 const char *
97 
99 
108 const char *
110 
113 void
114 rmw_reset_error(void);
115 
116 #if __cplusplus
117 }
118 #endif
119 
120 #endif // RMW__ERROR_HANDLING_H_
#define RMW_PUBLIC
Definition: visibility_control.h:48
struct rmw_error_state_t rmw_error_state_t
Struct which encapsulates the error state set by RMW_SET_ERROR_MSG().
const char * rmw_get_error_string(void)
Return the error message followed by , at <file>:<line>, or NULL.
const char * rmw_get_error_string_safe(void)
Return the error message followed by , at <file>:<line> if set, else "error not set".
const rmw_error_state_t * rmw_get_error_state(void)
Return an rmw_error_state_t which was set with rmw_set_error_state().
void rmw_set_error_state(const char *error_msg, const char *file, size_t line_number)
Set the error message, as well as the file and line on which it occurred.
const char * message
Definition: error_handling.h:32
bool rmw_error_is_set(void)
Return true if the error is set, otherwise false.
void rmw_reset_error(void)
Resets the error state by clearing any previously set error state.
const char * file
Definition: error_handling.h:33
size_t line_number
Definition: error_handling.h:34
Struct which encapsulates the error state set by RMW_SET_ERROR_MSG().
Definition: error_handling.h:30