waterlinkedsonar
C++ client library for the Water Linked Sonar 3D-15
Loading...
Searching...
No Matches
errors.hpp
Go to the documentation of this file.
1
3
4#ifndef WATERLINKEDSONAR_HTTP_ERRORS_HPP
5#define WATERLINKEDSONAR_HTTP_ERRORS_HPP
6
7#include <stdexcept>
8#include <string>
9
10namespace waterlinked::sonar {
11
13class HttpError : public std::runtime_error {
14 public:
17 HttpError(const std::string& what, int status_code)
18 : std::runtime_error(what), status_code_(status_code) {}
19
21 [[nodiscard]] int status_code() const noexcept { return status_code_; }
22
23 private:
24 int status_code_;
25};
26
28class VersionError : public std::runtime_error {
29 public:
33 VersionError(const std::string& what, const std::string& min_version,
34 const std::string& device_version)
35 : std::runtime_error(what + " requires Sonar 3D-15 release " +
36 min_version + " or newer; device is " +
37 device_version) {}
38};
39
41class ProtocolError : public std::runtime_error {
42 public:
44 explicit ProtocolError(const std::string& what) : std::runtime_error(what) {}
45};
46
50 public:
53 : HttpError("system time is already synchronized", 409) {}
54};
55
59 public:
61 ForceSyncOngoingError() : HttpError("a force-sync is already ongoing", 409) {}
62};
63
64} // namespace waterlinked::sonar
65
66#endif // WATERLINKEDSONAR_HTTP_ERRORS_HPP
SonarClient::force_sync_ntp() was called while another force-sync is running (HTTP 409).
Definition errors.hpp:58
ForceSyncOngoingError()
Sets status_code() to 409.
Definition errors.hpp:61
Request failure or non-2xx HTTP response.
Definition errors.hpp:13
HttpError(const std::string &what, int status_code)
Definition errors.hpp:17
int status_code() const noexcept
HTTP status of the response, or 0 when no response arrived.
Definition errors.hpp:21
The device answered with a body that does not match the API.
Definition errors.hpp:41
ProtocolError(const std::string &what)
Definition errors.hpp:44
SonarClient::set_time_manual() was called while the device clock is NTP-synchronized (HTTP 409).
Definition errors.hpp:49
TimeAlreadySynchronizedError()
Sets status_code() to 409.
Definition errors.hpp:52
The device firmware is older than the operation requires.
Definition errors.hpp:28
VersionError(const std::string &what, const std::string &min_version, const std::string &device_version)
Definition errors.hpp:33