Skip to content

Commit

Permalink
Clear rcutils error on failure (#163)
Browse files Browse the repository at this point in the history
* Clear rcutils error on failure

rcutils logging sets error messages on failure as of ros2/rcutils#65

* logging_macros.h isn't needed anymore

RCUTILS_LOGGING_AUTOINIT was moved to rcutils/logging.h
  • Loading branch information
dhood authored Dec 1, 2017
1 parent c389052 commit f1be687
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rclpy/src/rclpy/_rclpy_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#include <Python.h>

#include <rcutils/error_handling.h>
#include <rcutils/logging.h>
#include <rcutils/logging_macros.h>
#include <rcutils/time.h>

/// Initialize the logging system.
Expand All @@ -30,6 +30,7 @@ rclpy_logging_initialize(PyObject * Py_UNUSED(self), PyObject * Py_UNUSED(args))
if (ret != RCUTILS_RET_OK) {
PyErr_Format(PyExc_RuntimeError,
"Failed to initialize logging system, return code: %d\n", ret);
rcutils_reset_error();
return NULL;
}
Py_RETURN_NONE;
Expand All @@ -48,6 +49,7 @@ rclpy_logging_shutdown(PyObject * Py_UNUSED(self), PyObject * Py_UNUSED(args))
if (ret != RCUTILS_RET_OK) {
PyErr_Format(PyExc_RuntimeError,
"Failed to shutdown logging system, return code: %d\n", ret);
rcutils_reset_error();
return NULL;
}
Py_RETURN_NONE;
Expand All @@ -73,6 +75,7 @@ rclpy_logging_get_logger_severity_threshold(PyObject * Py_UNUSED(self), PyObject
PyErr_Format(PyExc_RuntimeError,
"Failed to get severity threshold for logger \"%s\", return code: %d\n",
name, severity);
rcutils_reset_error();
return NULL;
}
return PyLong_FromLong(severity);
Expand Down Expand Up @@ -100,6 +103,7 @@ rclpy_logging_set_logger_severity_threshold(PyObject * Py_UNUSED(self), PyObject
PyErr_Format(PyExc_RuntimeError,
"Failed to set severity threshold \"%d\" for logger \"%s\", return code: %d\n",
severity, name, ret);
rcutils_reset_error();
return NULL;
}
Py_RETURN_NONE;
Expand Down Expand Up @@ -128,6 +132,7 @@ rclpy_logging_get_logger_effective_severity_threshold(PyObject * Py_UNUSED(self)
PyErr_Format(PyExc_RuntimeError,
"Failed to get effective severity threshold for logger \"%s\", return code: %d\n",
name, severity);
rcutils_reset_error();
return NULL;
}
return PyLong_FromLong(severity);
Expand Down

0 comments on commit f1be687

Please sign in to comment.