CreOS SDK
The CreOS SDK allows you to interact with Avular robots
 
Loading...
Searching...
No Matches
errors.hpp
1// Copyright (C) 2024 Avular Holding B.V. - All Rights Reserved
2// You may use this code under the terms of the Avular
3// Software End-User License Agreement.
4//
5// You should have received a copy of the Avular
6// Software End-User License Agreement license with
7// this file, or download it from: avular.com/eula
8//
9/*****************************************************************************
10 * Created on: 2024 June 21
11 * Author: Robbert-Jan de Jager
12 *
13 * @file This header file declares the possible errors that can occur in the CreOS
14 * client library.
15 *
16 ****************************************************************************/
17#pragma once
18
19#include <creos/messages/error.hpp>
20#include <creos/utils_global.hpp>
21#include <exception>
22#include <source_location>
23#include <string>
24
25namespace creos {
26
32class CREOS_UTILS_API Exception : public std::exception {
33public:
34 Exception(const std::string& message) : message_(message) {}
35
36 Exception(const Exception& other) : message_(other.message_) {}
37
38 virtual ~Exception() = default;
39
43 const char* what() const noexcept override { return message_.c_str(); }
44
45private:
46 std::string message_;
47};
48
55class CREOS_UTILS_API ConnectionError : public Exception {
56public:
57 ConnectionError(const std::string& message) : Exception(message) {}
58
59 ~ConnectionError() override = default;
60};
61
65class CREOS_UTILS_API NotImplementedError : public Exception {
66public:
67 NotImplementedError(const std::string& message = std::source_location::current().function_name())
68 : Exception(message) {}
69
70 ~NotImplementedError() override = default;
71};
72
76class CREOS_UTILS_API InvalidArgumentError : public Exception {
77public:
78 InvalidArgumentError(const std::string& message) : Exception(message) {}
79
80 ~InvalidArgumentError() override = default;
81};
82
88class CREOS_UTILS_API TimeoutError : public Exception {
89public:
90 TimeoutError(const std::string& message) : Exception(message) {}
91
92 ~TimeoutError() override = default;
93};
94
99
105class CREOS_UTILS_API ServiceCallError : public Exception {
106public:
107 ServiceCallError(ErrorCode code, const std::string& message) : Exception(message), code_(code) {}
108
109 ~ServiceCallError() override = default;
110
111 ErrorCode code() const { return code_; }
112
113private:
114 ErrorCode code_{ErrorCode::kUnknown};
115};
116
120class CREOS_UTILS_API UnsupportedError : public Exception {
121public:
122 UnsupportedError(const std::string& message) : Exception(message) {}
123
124 ~UnsupportedError() override = default;
125};
126
130class CREOS_UTILS_API AlreadyExistsError : public Exception {
131public:
132 AlreadyExistsError(const std::string& message) : Exception(message) {}
133
134 ~AlreadyExistsError() override = default;
135};
136
140class CREOS_UTILS_API PublicationError : public Exception {
141public:
142 PublicationError(const std::string& message) : Exception(message) {}
143
144 ~PublicationError() override = default;
145};
146
150class CREOS_UTILS_API SubscriptionError : public Exception {
151public:
152 SubscriptionError(const std::string& message) : Exception(message) {}
153
154 ~SubscriptionError() override = default;
155};
156
157} // namespace creos
Something already exists when trying to create it.
Definition errors.hpp:130
Connection error.
Definition errors.hpp:55
Exception class for the CreOS client library.
Definition errors.hpp:32
const char * what() const noexcept override
Returns the error message.
Definition errors.hpp:43
Invalid argument error.
Definition errors.hpp:76
The function is not implemented.
Definition errors.hpp:65
An error occurred while publishing data.
Definition errors.hpp:140
Service call failure.
Definition errors.hpp:105
An error occurred while subscribing to data.
Definition errors.hpp:150
Timeout error.
Definition errors.hpp:88
A part of the API is not supported by the connected robot.
Definition errors.hpp:120
ErrorCode
Error codes that indicate what went wrong.
Definition error.hpp:24
The main namespace for the CreOS client library.