Viam C++ SDK current
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <grpcpp/support/status.h>
6#include <stdexcept>
7#include <string>
8
9#include <viam/sdk/resource/resource_api.hpp>
10
11namespace viam {
12namespace sdk {
13
15
20enum class ErrorCondition : uint8_t {
21 k_general = 0, // Default condition
22 k_connection = 1, // Issue during connection establishment
23 k_duplicate_registration = 2, // API or API/Model pair has already been registered
24 k_duplicate_resource = 3, // Resource has already been added
25 k_grpc = 4, // gRPC error from remote machine
26 k_not_supported = 5, // Behavior not supported by the SDK
27 k_resource_not_found = 6 // Resource does not exist
28};
29
30std::error_condition make_error_condition(ErrorCondition e);
31
35class Exception : public std::runtime_error {
36 public:
37 explicit Exception(ErrorCondition condition, const std::string& what);
38 explicit Exception(const std::string& what);
39 virtual ~Exception();
40
41 const std::error_condition& condition() const noexcept;
42
43 private:
44 std::error_condition condition_;
45};
46
50class GRPCException : public Exception {
51 public:
52 explicit GRPCException(grpc::Status status);
53
54 const grpc::Status& status() const noexcept;
55
56 private:
57 grpc::Status status_;
58};
59
60} // namespace sdk
61} // namespace viam
62
63namespace std {
64template <>
65struct is_error_condition_enum<viam::sdk::ErrorCondition> : true_type {};
66} // namespace std
Defines a set of a error conditions to be used in conjunction with Exception.
Defines an exception type for the SDK.
Definition exception.hpp:35
Defines an exception from a gRPC interaction.
Definition exception.hpp:50