16 #ifndef IMPALA_COMMON_STATUS_H
17 #define IMPALA_COMMON_STATUS_H
22 #include <boost/lexical_cast.hpp>
26 #include "gen-cpp/Status_types.h"
27 #include "gen-cpp/ErrorCodes_types.h"
28 #include "gen-cpp/TCLIService_types.h"
31 #define STATUS_API_VERSION 2
83 typedef strings::internal::SubstituteArg
ArgType;
136 Status(
const std::string& error_msg);
158 Status(
const TStatus& status);
166 Status(
const apache::hive::service::cli::thrift::TStatus& hs2_status);
170 Status&
operator=(
const apache::hive::service::cli::thrift::TStatus& hs2_status);
175 return msg_ != NULL &&
msg_->
error() == TErrorCode::CANCELLED;
180 &&
msg_->
error() == TErrorCode::MEM_LIMIT_EXCEEDED;
185 &&
msg_->
error() == TErrorCode::RECOVERABLE_ERROR;
190 DCHECK_NOTNULL(
msg_);
198 DCHECK_NOTNULL(
msg_);
213 template <
typename T>
void SetTStatus(T* status_container)
const {
214 ToThrift(&status_container->status);
215 status_container->__isset.status =
true;
219 void ToThrift(TStatus* status)
const;
226 TErrorCode::type
code()
const {
234 Status(
const std::string& error_msg,
bool silent);
242 #define RETURN_IF_ERROR(stmt) \
244 Status __status__ = (stmt); \
245 if (UNLIKELY(!__status__.ok())) return __status__; \
248 #define EXIT_IF_ERROR(stmt) \
250 Status __status__ = (stmt); \
251 if (UNLIKELY(!__status__.ok())) { \
252 EXIT_WITH_ERROR(__status__.GetDetail()); \
256 #define EXIT_WITH_ERROR(msg) \
const std::string GetDetail() const
static const Status DEPRECATED_RPC
strings::internal::SubstituteArg ArgType
Status(const Status &status)
copy c'tor makes copy of error detail so Status can be returned by value
void MergeStatus(const Status &status)
TErrorCode::type error() const
void AddDetail(const std::string &msg)
Add a detail string. Calling this method is only defined on a non-OK message.
Status & operator=(const Status &status)
same as copy c'tor
TErrorCode::type code() const
void ToThrift(TStatus *status) const
Convert into TStatus.
void SetTStatus(T *status_container) const
static const Status CANCELLED
static Status Expected(const std::string &error_msg)
Create a status instance that represents an expected error and will not be logged.
static const Status MEM_LIMIT_EXCEEDED
void SetErrorMsg(const ErrorMsg &m)
const ErrorMsg & msg() const
Returns the error message associated with a non-successful status.
bool IsMemLimitExceeded() const
bool IsRecoverableError() const