Don't include SliceBuilder.h in Status.h.
This commit is contained in:
parent
65c3c89ad6
commit
5e7adcd1cb
@ -7,7 +7,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/format.h"
|
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/SliceBuilder.h"
|
#include "td/utils/SliceBuilder.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
@ -99,7 +98,7 @@ class ParserImpl {
|
|||||||
}
|
}
|
||||||
SliceT res = read_till_nofail(c);
|
SliceT res = read_till_nofail(c);
|
||||||
if (ptr_ == end_ || ptr_[0] != c) {
|
if (ptr_ == end_ || ptr_[0] != c) {
|
||||||
status_ = Status::Error(PSLICE() << "Read till " << tag("char", c) << " failed");
|
status_ = Status::Error(PSLICE() << "Read till '" << c << "' failed");
|
||||||
return SliceT();
|
return SliceT();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@ -126,7 +125,7 @@ class ParserImpl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ptr_ == end_ || ptr_[0] != c) {
|
if (ptr_ == end_ || ptr_[0] != c) {
|
||||||
status_ = Status::Error(PSLICE() << "Skip " << tag("char", c) << " failed");
|
status_ = Status::Error(PSLICE() << "Skip '" << c << "' failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptr_++;
|
ptr_++;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
//
|
//
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
|
#include "td/utils/SliceBuilder.h"
|
||||||
|
|
||||||
#if TD_PORT_WINDOWS
|
#if TD_PORT_WINDOWS
|
||||||
#include "td/utils/port/wstring_convert.h"
|
#include "td/utils/port/wstring_convert.h"
|
||||||
#endif
|
#endif
|
||||||
@ -55,4 +57,32 @@ string winerror_to_string(int code) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Status Status::move_as_error_prefix(Slice prefix) const {
|
||||||
|
CHECK(is_error());
|
||||||
|
Info info = get_info();
|
||||||
|
switch (info.error_type) {
|
||||||
|
case ErrorType::General:
|
||||||
|
return Error(code(), PSLICE() << prefix << message());
|
||||||
|
case ErrorType::Os:
|
||||||
|
return Status(false, ErrorType::Os, code(), PSLICE() << prefix << message());
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Status Status::move_as_error_suffix(Slice suffix) const TD_WARN_UNUSED_RESULT {
|
||||||
|
CHECK(is_error());
|
||||||
|
Info info = get_info();
|
||||||
|
switch (info.error_type) {
|
||||||
|
case ErrorType::General:
|
||||||
|
return Error(code(), PSLICE() << message() << suffix);
|
||||||
|
case ErrorType::Os:
|
||||||
|
return Status(false, ErrorType::Os, code(), PSLICE() << message() << suffix);
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/ScopeGuard.h"
|
#include "td/utils/ScopeGuard.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/SliceBuilder.h"
|
|
||||||
#include "td/utils/StackAllocator.h"
|
#include "td/utils/StackAllocator.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
|
|
||||||
@ -325,32 +324,9 @@ class Status {
|
|||||||
return status.move_as_error_suffix(message());
|
return status.move_as_error_suffix(message());
|
||||||
}
|
}
|
||||||
|
|
||||||
Status move_as_error_prefix(Slice prefix) const TD_WARN_UNUSED_RESULT {
|
Status move_as_error_prefix(Slice prefix) const TD_WARN_UNUSED_RESULT;
|
||||||
CHECK(is_error());
|
|
||||||
Info info = get_info();
|
Status move_as_error_suffix(Slice suffix) const TD_WARN_UNUSED_RESULT;
|
||||||
switch (info.error_type) {
|
|
||||||
case ErrorType::General:
|
|
||||||
return Error(code(), PSLICE() << prefix << message());
|
|
||||||
case ErrorType::Os:
|
|
||||||
return Status(false, ErrorType::Os, code(), PSLICE() << prefix << message());
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Status move_as_error_suffix(Slice suffix) const TD_WARN_UNUSED_RESULT {
|
|
||||||
CHECK(is_error());
|
|
||||||
Info info = get_info();
|
|
||||||
switch (info.error_type) {
|
|
||||||
case ErrorType::General:
|
|
||||||
return Error(code(), PSLICE() << message() << suffix);
|
|
||||||
case ErrorType::Os:
|
|
||||||
return Status(false, ErrorType::Os, code(), PSLICE() << message() << suffix);
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Info {
|
struct Info {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user