ErrorCategory:
publicstd::error_category
17 const char* name() const noexcept
override{
return "KafkaError"; }
18std::string message(
intev)
const override{
returnrd_kafka_err2str(
static_cast<rd_kafka_resp_err_t
>(ev)); }
20 template<
typenameT =
void>
21 structGlobal {
staticErrorCategory category; };
24 template<
typenameT>
25ErrorCategory ErrorCategory::Global<T>::category;
35 explicit Error(rd_kafka_error_t* error =
nullptr): _rkError(error, RkErrorDeleter) {}
37 explicit Error(rd_kafka_resp_err_t respErr): _respErr(respErr) {}
39 Error(rd_kafka_resp_err_t respErr, std::string
message,
boolfatal =
false)
40: _respErr(respErr), _message(std::move(
message)), _isFatal(fatal) {}
42 Error(
const Error& error) { *
this= error; }
47 if(
this== &error)
return*
this;
51_respErr =
static_cast<rd_kafka_resp_err_t
>(error.
value());
52_message = error._message;
63 explicit operatorbool()
const{
return static_cast<bool>(
value()); }
68 explicit operatorstd::error_code()
const 70 return{
value(), ErrorCategory::Global<>::category};
83 return static_cast<int>(_rkError ? rd_kafka_error_code(_rkError.get()) : _respErr);
91 return_message ? *_message :
92(_rkError ? rd_kafka_error_string(_rkError.get()) : rd_kafka_err2str(_respErr));
100std::ostringstream oss;
102oss << rd_kafka_err2str(static_cast<rd_kafka_resp_err_t>(
value())) <<
" ["<<
value() <<
"]"<< (
isFatal() ?
" fatal":
"");
104 if(
autoretriable =
isRetriable()) oss <<
" | "<< (*retriable ?
"retriable":
"non-retriable");
105 if(_message) oss <<
" | "<< *_message;
115 return_rkError ? rd_kafka_error_is_fatal(_rkError.get()) : _isFatal;
123 return_rkError ? rd_kafka_error_is_retriable(_rkError.get()) : _isRetriable;
135 return_rkError ? rd_kafka_error_txn_requires_abort(_rkError.get()) :
false;
139rd_kafka_error_shared_ptr _rkError;
140rd_kafka_resp_err_t _respErr{};
141Optional<std::string> _message;
142 bool_isFatal =
false;
143 bool_txnRequiresAbort =
false;
144Optional<bool> _isRetriable;
Unified error type.
Definition: Error.h:32
bool isFatal() const
Fatal error indicates that the client instance is no longer usable.
Definition: Error.h:113
bool transactionRequiresAbort() const
Show whether the error is an abortable transaction error.
Definition: Error.h:133
std::string message() const
Readable error string.
Definition: Error.h:89
int value() const
Obtains the underlying error code value.
Definition: Error.h:81
Optional< bool > isRetriable() const
Show whether the operation may be retried.
Definition: Error.h:121
std::string toString() const
Detailed error string.
Definition: Error.h:98
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4