Kudu C++ client API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros
status.h File Reference
#include <stdint.h>
#include <string>
#include "kudu/client/stubs.h"
#include "kudu/util/kudu_export.h"
#include "kudu/util/slice.h"

Go to the source code of this file.

Classes

class  kudu::Status
 A representation of an operation's outcome. More...
 

Namespaces

 kudu
 

Macros

#define KUDU_RETURN_NOT_OK(s)
 Return the given status if it is not OK. More...
 
#define KUDU_RETURN_NOT_OK_PREPEND(s, msg)
 Return the given status if it is not OK, but first clone it and prepend the given message. More...
 
#define KUDU_RETURN_NOT_OK_RET(to_call, to_return)
 Return to_return if to_call returns a bad status. The substitution for 'to_return' may reference the variable s for the bad status. More...
 
#define KUDU_WARN_NOT_OK(to_call, warning_prefix)
 Emit a warning if to_call returns a bad status. More...
 
#define KUDU_LOG_AND_RETURN(level, status)
 Log the given status and return immediately. More...
 
#define KUDU_CHECK_OK_PREPEND(to_call, msg)
 If to_call returns a bad status, CHECK immediately with a logged message of msg followed by the status. More...
 
#define KUDU_CHECK_OK(s)   KUDU_CHECK_OK_PREPEND(s, "Bad status")
 If the status is bad, CHECK immediately, appending the status to the logged message.
 

Detailed Description

This header is used in both the Kudu build as well as in builds of applications that use the Kudu C++ client. In the latter we need to be careful to "namespace" our macros, to avoid colliding or overriding with similarly named macros belonging to the application.

KUDU_HEADERS_USE_SHORT_STATUS_MACROS handles this behavioral change. When defined, we're building Kudu and:

Macro Definition Documentation

#define KUDU_CHECK_OK_PREPEND (   to_call,
  msg 
)
Value:
do { \
::kudu::Status _s = (to_call); \
KUDU_CHECK(_s.ok()) << (msg) << ": " << _s.ToString(); \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
bool ok() const
Definition: status.h:229
std::string ToString() const

If to_call returns a bad status, CHECK immediately with a logged message of msg followed by the status.

#define KUDU_LOG_AND_RETURN (   level,
  status 
)
Value:
do { \
::kudu::Status _s = (status); \
KUDU_LOG(level) << _s.ToString(); \
return _s; \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
std::string ToString() const

Log the given status and return immediately.

#define KUDU_RETURN_NOT_OK (   s)
Value:
do { \
::kudu::Status _s = (s); \
if (PREDICT_FALSE(!_s.ok())) return _s; \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
bool ok() const
Definition: status.h:229

Return the given status if it is not OK.

#define KUDU_RETURN_NOT_OK_PREPEND (   s,
  msg 
)
Value:
do { \
::kudu::Status _s = (s); \
if (PREDICT_FALSE(!_s.ok())) return _s.CloneAndPrepend(msg); \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
bool ok() const
Definition: status.h:229

Return the given status if it is not OK, but first clone it and prepend the given message.

#define KUDU_RETURN_NOT_OK_RET (   to_call,
  to_return 
)
Value:
do { \
::kudu::Status s = (to_call); \
if (PREDICT_FALSE(!s.ok())) return (to_return); \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
bool ok() const
Definition: status.h:229

Return to_return if to_call returns a bad status. The substitution for 'to_return' may reference the variable s for the bad status.

#define KUDU_WARN_NOT_OK (   to_call,
  warning_prefix 
)
Value:
do { \
::kudu::Status _s = (to_call); \
if (PREDICT_FALSE(!_s.ok())) { \
KUDU_LOG(WARNING) << (warning_prefix) << ": " << _s.ToString(); \
} \
} while (0);
A representation of an operation's outcome.
Definition: status.h:106
bool ok() const
Definition: status.h:229
std::string ToString() const

Emit a warning if to_call returns a bad status.