Skip to content

Commit a76b888

Browse files
committed
Make code() public and add message()
1 parent 34e7f48 commit a76b888

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cpp/src/arrow/util/status.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ class ARROW_EXPORT Status {
138138
// Get the POSIX code associated with this Status, or -1 if there is none.
139139
int16_t posix_code() const;
140140

141+
StatusCode code() const {
142+
return ((state_ == NULL) ? StatusCode::OK : static_cast<StatusCode>(state_[4]));
143+
}
144+
145+
std::string message() const {
146+
uint32_t length;
147+
memcpy(&length, state_, sizeof(length));
148+
std::string msg;
149+
msg.append((state_ + 7), length);
150+
return msg;
151+
}
152+
141153
private:
142154
// OK status has a NULL state_. Otherwise, state_ is a new[] array
143155
// of the following form:
@@ -147,10 +159,6 @@ class ARROW_EXPORT Status {
147159
// state_[7..] == message
148160
const char* state_;
149161

150-
StatusCode code() const {
151-
return ((state_ == NULL) ? StatusCode::OK : static_cast<StatusCode>(state_[4]));
152-
}
153-
154162
Status(StatusCode code, const std::string& msg, int16_t posix_code);
155163
static const char* CopyState(const char* s);
156164
};

0 commit comments

Comments
 (0)