Skip to content

Commit b802e7e

Browse files
committed
exceptions.hpp + cpp
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
1 parent 30aa3fc commit b802e7e

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

rclpy/src/rclpy/exceptions.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2021 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+
#include "exceptions.hpp"
16+
17+
#include <rcl/error_handling.h>
18+
19+
#include <stdexcept>
20+
#include <string>
21+
22+
namespace rclpy
23+
{
24+
std::string append_rcl_error(std::string prepend)
25+
{
26+
prepend += ": ";
27+
prepend += rcl_get_error_string().str;
28+
rcl_reset_error();
29+
return prepend;
30+
}
31+
32+
RCLError::RCLError(const std::string & error_text)
33+
: std::runtime_error(append_rcl_error(error_text))
34+
{
35+
}
36+
} // namespace rclpy

rclpy/src/rclpy/exceptions.hpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,18 @@
1515
#ifndef RCLPY__EXCEPTIONS_HPP_
1616
#define RCLPY__EXCEPTIONS_HPP_
1717

18-
#include <rcl/error_handling.h>
19-
2018
#include <stdexcept>
2119
#include <string>
2220

2321
namespace rclpy
2422
{
2523

26-
std::string append_rcl_error(std::string prepend)
27-
{
28-
prepend += ": ";
29-
prepend += rcl_get_error_string().str;
30-
rcl_reset_error();
31-
return prepend;
32-
}
24+
std::string append_rcl_error(std::string prepend);
3325

3426
class RCLError : public std::runtime_error
3527
{
3628
public:
37-
explicit RCLError(const std::string & error_text)
38-
: std::runtime_error(append_rcl_error(error_text))
39-
{
40-
}
29+
explicit RCLError(const std::string & error_text);
4130

4231
~RCLError() = default;
4332
};

0 commit comments

Comments
 (0)