std::string Status::ToString()

in src/util/status.cc [40:92]


std::string Status::ToString() const {
  char tmp[30];
  const char* type;
  switch(code_) {
  case kOk:
    return "OK";
  case kNotFound:
    type = "NotFound: ";
    break;
  case kCorruption:
    type = "Corruption: ";
    break;
  case kNotSupported:
    type = "Not implemented: ";
    break;
  case kInvalidArgument:
    type = "Invalid argument: ";
    break;
  case kIOError:
    type = "IO error: ";
    break;
  case kMergeInProgress:
    type = "Merge in progress: ";
    break;
  case kUnableToMerge:
    type = "Cannot merge: ";
    break;
  case kIncomplete:
    type = "Result incomplete: ";
    break;
  case kShutdownInProgress:
    type = "Shutdown in progress: ";
    break;
  case kAborted:
    type = "Operation aborted: ";
    break;
  case kBusy:
    type = "Resource busy: ";
    break;
  default:
    snprintf(tmp, sizeof(tmp), "Unknown code(%d): ",
             static_cast<int>(code()));
    type = tmp;
    break;
  }
  std::string result(type);
  if(state_ != nullptr) {
    uint32_t length;
    memcpy(&length, state_, sizeof(length));
    result.append(state_ + 4, length);
  }
  return result;
}