iceberg-cpp
Loading...
Searching...
No Matches
error_handlers.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include <cstdint>
23#include <memory>
24#include <string>
25
26#include "iceberg/catalog/rest/iceberg_rest_export.h"
28#include "iceberg/result.h"
29
32
33namespace iceberg::rest {
34
37class ICEBERG_REST_EXPORT ErrorHandler {
38 public:
39 virtual ~ErrorHandler() = default;
40
45 virtual Status Accept(const ErrorResponse& error) const = 0;
46
52 virtual Result<ErrorResponse> ParseResponse(uint32_t code,
53 const std::string& text) const = 0;
54};
55
57class ICEBERG_REST_EXPORT DefaultErrorHandler : public ErrorHandler {
58 public:
60 static const std::shared_ptr<DefaultErrorHandler>& Instance();
61
62 Status Accept(const ErrorResponse& error) const override;
63 Result<ErrorResponse> ParseResponse(uint32_t code,
64 const std::string& text) const override;
65
66 protected:
67 constexpr DefaultErrorHandler() = default;
68};
69
71class ICEBERG_REST_EXPORT NamespaceErrorHandler : public DefaultErrorHandler {
72 public:
74 static const std::shared_ptr<NamespaceErrorHandler>& Instance();
75
76 Status Accept(const ErrorResponse& error) const override;
77
78 protected:
79 constexpr NamespaceErrorHandler() = default;
80};
81
83class ICEBERG_REST_EXPORT DropNamespaceErrorHandler final : public NamespaceErrorHandler {
84 public:
86 static const std::shared_ptr<DropNamespaceErrorHandler>& Instance();
87
88 Status Accept(const ErrorResponse& error) const override;
89
90 private:
91 constexpr DropNamespaceErrorHandler() = default;
92};
93
95class ICEBERG_REST_EXPORT ConfigErrorHandler final : public DefaultErrorHandler {
96 public:
98 static const std::shared_ptr<ConfigErrorHandler>& Instance();
99
100 Status Accept(const ErrorResponse& error) const override;
101
102 private:
103 constexpr ConfigErrorHandler() = default;
104};
105
107class ICEBERG_REST_EXPORT TableErrorHandler final : public DefaultErrorHandler {
108 public:
110 static const std::shared_ptr<TableErrorHandler>& Instance();
111
112 Status Accept(const ErrorResponse& error) const override;
113
114 private:
115 constexpr TableErrorHandler() = default;
116};
117
119class ICEBERG_REST_EXPORT TableCommitErrorHandler : public DefaultErrorHandler {
120 public:
122 static const std::shared_ptr<TableCommitErrorHandler>& Instance();
123
124 Status Accept(const ErrorResponse& error) const override;
125
126 protected:
127 constexpr TableCommitErrorHandler() = default;
128};
129
131class ICEBERG_REST_EXPORT CreateTableErrorHandler final : public TableCommitErrorHandler {
132 public:
134 static const std::shared_ptr<CreateTableErrorHandler>& Instance();
135
136 Status Accept(const ErrorResponse& error) const override;
137
138 private:
139 constexpr CreateTableErrorHandler() = default;
140};
141
143class ICEBERG_REST_EXPORT ViewErrorHandler final : public DefaultErrorHandler {
144 public:
146 static const std::shared_ptr<ViewErrorHandler>& Instance();
147
148 Status Accept(const ErrorResponse& error) const override;
149
150 private:
151 constexpr ViewErrorHandler() = default;
152};
153
155class ICEBERG_REST_EXPORT ViewCommitErrorHandler final : public DefaultErrorHandler {
156 public:
158 static const std::shared_ptr<ViewCommitErrorHandler>& Instance();
159
160 Status Accept(const ErrorResponse& error) const override;
161
162 private:
163 constexpr ViewCommitErrorHandler() = default;
164};
165
167class ICEBERG_REST_EXPORT PlanErrorHandler final : public DefaultErrorHandler {
168 public:
169 static const std::shared_ptr<PlanErrorHandler>& Instance();
170
171 Status Accept(const ErrorResponse& error) const override;
172
173 private:
174 constexpr PlanErrorHandler() = default;
175};
176
178class ICEBERG_REST_EXPORT PlanTaskErrorHandler final : public DefaultErrorHandler {
179 public:
180 static const std::shared_ptr<PlanTaskErrorHandler>& Instance();
181
182 Status Accept(const ErrorResponse& error) const override;
183
184 private:
185 constexpr PlanTaskErrorHandler() = default;
186};
187
189class ICEBERG_REST_EXPORT OAuthErrorHandler final : public ErrorHandler {
190 public:
191 static const std::shared_ptr<OAuthErrorHandler>& Instance();
192
193 Status Accept(const ErrorResponse& error) const override;
194 Result<ErrorResponse> ParseResponse(uint32_t code,
195 const std::string& text) const override;
196
197 private:
198 constexpr OAuthErrorHandler() = default;
199};
200
201} // namespace iceberg::rest
Error handler for the catalog config endpoint.
Definition error_handlers.h:95
Table create commit operation error handler.
Definition error_handlers.h:131
Default error handler for REST API responses.
Definition error_handlers.h:57
Error handler for drop namespace operations.
Definition error_handlers.h:83
Error handler interface for processing REST API error responses. Maps HTTP status codes to appropriat...
Definition error_handlers.h:37
virtual Status Accept(const ErrorResponse &error) const =0
Process an error response and return an appropriate Error.
virtual Result< ErrorResponse > ParseResponse(uint32_t code, const std::string &text) const =0
Parse an HTTP error response body.
Namespace-specific error handler for create/read/update operations.
Definition error_handlers.h:71
OAuth token endpoint error handler.
Definition error_handlers.h:189
Plan operation error handler.
Definition error_handlers.h:167
Fetch scan tasks operation error handler.
Definition error_handlers.h:178
Table commit operation error handler.
Definition error_handlers.h:119
Table-level error handler.
Definition error_handlers.h:107
View commit operation error handler.
Definition error_handlers.h:155
View-level error handler.
Definition error_handlers.h:143
JSON error payload returned in a response with further details on the error.
Definition types.h:67