Added source-location to all ecs.

Closes #2475.
This commit is contained in:
Klemens
2022-12-17 18:22:18 +08:00
committed by Klemens Morgenstern
parent ce99605ef9
commit 860bfbdeab
8 changed files with 117 additions and 103 deletions

View File

@@ -246,7 +246,9 @@ teardown(
if( s.in_->fc && if( s.in_->fc &&
s.in_->fc->fail(ec)) s.in_->fc->fail(ec))
ec = net::error::eof; {
BOOST_BEAST_ASSIGN_EC(ec, net::error::eof);
}
else else
ec = {}; ec = {};
} }

View File

@@ -140,7 +140,7 @@ find_eol(
} }
if(*it != '\n') if(*it != '\n')
{ {
ec = error::bad_line_ending; BOOST_BEAST_ASSIGN_EC(ec, error::bad_line_ending);
return nullptr; return nullptr;
} }
ec = {}; ec = {};
@@ -249,7 +249,7 @@ parse_token_to_eol(
{ {
if(p >= last) if(p >= last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return p; return p;
} }
if(BOOST_UNLIKELY(! is_print(*p))) if(BOOST_UNLIKELY(! is_print(*p)))
@@ -264,12 +264,12 @@ found_control:
{ {
if(++p >= last) if(++p >= last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return last; return last;
} }
if(*p++ != '\n') if(*p++ != '\n')
{ {
ec = error::bad_line_ending; BOOST_BEAST_ASSIGN_EC(ec, error::bad_line_ending);
return last; return last;
} }
token_last = p - 2; token_last = p - 2;
@@ -313,7 +313,7 @@ parse_method(
{ {
if(it + 1 > last) if(it + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(! detail::is_token_char(*it)) if(! detail::is_token_char(*it))
@@ -321,18 +321,18 @@ parse_method(
} }
if(it + 1 > last) if(it + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it != ' ') if(*it != ' ')
{ {
ec = error::bad_method; BOOST_BEAST_ASSIGN_EC(ec, error::bad_method);
return; return;
} }
if(it == first) if(it == first)
{ {
// cannot be empty // cannot be empty
ec = error::bad_method; BOOST_BEAST_ASSIGN_EC(ec, error::bad_method);
return; return;
} }
result = make_string(first, it++); result = make_string(first, it++);
@@ -350,7 +350,7 @@ parse_target(
{ {
if(it + 1 > last) if(it + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(! is_pathchar(*it)) if(! is_pathchar(*it))
@@ -358,18 +358,18 @@ parse_target(
} }
if(it + 1 > last) if(it + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it != ' ') if(*it != ' ')
{ {
ec = error::bad_target; BOOST_BEAST_ASSIGN_EC(ec, error::bad_target);
return; return;
} }
if(it == first) if(it == first)
{ {
// cannot be empty // cannot be empty
ec = error::bad_target; BOOST_BEAST_ASSIGN_EC(ec, error::bad_target);
return; return;
} }
result = make_string(first, it++); result = make_string(first, it++);
@@ -383,48 +383,48 @@ parse_version(
{ {
if(it + 8 > last) if(it + 8 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it++ != 'H') if(*it++ != 'H')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(*it++ != 'T') if(*it++ != 'T')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(*it++ != 'T') if(*it++ != 'T')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(*it++ != 'P') if(*it++ != 'P')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(*it++ != '/') if(*it++ != '/')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(! is_digit(*it)) if(! is_digit(*it))
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
result = 10 * (*it++ - '0'); result = 10 * (*it++ - '0');
if(*it++ != '.') if(*it++ != '.')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(! is_digit(*it)) if(! is_digit(*it))
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
result += *it++ - '0'; result += *it++ - '0';
@@ -439,30 +439,30 @@ parse_status(
// parse 3(digit) SP // parse 3(digit) SP
if(it + 4 > last) if(it + 4 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(! is_digit(*it)) if(! is_digit(*it))
{ {
ec = error::bad_status; BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
return; return;
} }
result = 100 * (*it++ - '0'); result = 100 * (*it++ - '0');
if(! is_digit(*it)) if(! is_digit(*it))
{ {
ec = error::bad_status; BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
return; return;
} }
result += 10 * (*it++ - '0'); result += 10 * (*it++ - '0');
if(! is_digit(*it)) if(! is_digit(*it))
{ {
ec = error::bad_status; BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
return; return;
} }
result += *it++ - '0'; result += *it++ - '0';
if(*it++ != ' ') if(*it++ != ' ')
{ {
ec = error::bad_status; BOOST_BEAST_ASSIGN_EC(ec, error::bad_status);
return; return;
} }
} }
@@ -481,7 +481,7 @@ parse_reason(
return; return;
if(! p) if(! p)
{ {
ec = error::bad_reason; BOOST_BEAST_ASSIGN_EC(ec, error::bad_reason);
return; return;
} }
result = make_string(first, token_last); result = make_string(first, token_last);
@@ -542,7 +542,7 @@ parse_field(
p, last, ranges1, sizeof(ranges1)-1); p, last, ranges1, sizeof(ranges1)-1);
if(! found && p >= last) if(! found && p >= last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
for(;;) for(;;)
@@ -552,20 +552,20 @@ parse_field(
if(! is_token[static_cast< if(! is_token[static_cast<
unsigned char>(*p)]) unsigned char>(*p)])
{ {
ec = error::bad_field; BOOST_BEAST_ASSIGN_EC(ec, error::bad_field);
return; return;
} }
++p; ++p;
if(p >= last) if(p >= last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
} }
if(p == first) if(p == first)
{ {
// empty name // empty name
ec = error::bad_field; BOOST_BEAST_ASSIGN_EC(ec, error::bad_field);
return; return;
} }
name = make_string(first, p); name = make_string(first, p);
@@ -578,7 +578,7 @@ parse_field(
{ {
if(p + 1 > last) if(p + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(! (*p == ' ' || *p == '\t')) if(! (*p == ' ' || *p == '\t'))
@@ -591,13 +591,13 @@ parse_field(
return; return;
if(! p) if(! p)
{ {
ec = error::bad_value; BOOST_BEAST_ASSIGN_EC(ec, error::bad_value);
return; return;
} }
// Look 1 char past the CRLF to handle obs-fold. // Look 1 char past the CRLF to handle obs-fold.
if(p + 1 > last) if(p + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
token_last = token_last =
@@ -614,7 +614,7 @@ parse_field(
buf.clear(); buf.clear();
if (!buf.try_append(first, token_last)) if (!buf.try_append(first, token_last))
{ {
ec = error::header_limit; BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
return; return;
} }
@@ -626,7 +626,7 @@ parse_field(
{ {
if(p + 1 > last) if(p + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(! (*p == ' ' || *p == '\t')) if(! (*p == ' ' || *p == '\t'))
@@ -639,13 +639,13 @@ parse_field(
return; return;
if(! p) if(! p)
{ {
ec = error::bad_value; BOOST_BEAST_ASSIGN_EC(ec, error::bad_value);
return; return;
} }
// Look 1 char past the CRLF to handle obs-fold. // Look 1 char past the CRLF to handle obs-fold.
if(p + 1 > last) if(p + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
token_last = trim_back(token_last, first); token_last = trim_back(token_last, first);
@@ -654,7 +654,7 @@ parse_field(
if (!buf.try_push_back(' ') || if (!buf.try_push_back(' ') ||
!buf.try_append(first, token_last)) !buf.try_append(first, token_last))
{ {
ec = error::header_limit; BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
return; return;
} }
} }
@@ -691,7 +691,7 @@ parse_chunk_extensions(
loop: loop:
if(it == last) if(it == last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it != ' ' && *it != '\t' && *it != ';') if(*it != ' ' && *it != '\t' && *it != ';')
@@ -704,7 +704,7 @@ loop:
++it; ++it;
if(it == last) if(it == last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it != ' ' && *it != '\t') if(*it != ' ' && *it != '\t')
@@ -714,7 +714,7 @@ loop:
// ';' // ';'
if(*it != ';') if(*it != ';')
{ {
ec = error::bad_chunk_extension; BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk_extension);
return; return;
} }
semi: semi:
@@ -724,7 +724,7 @@ semi:
{ {
if(it == last) if(it == last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*it != ' ' && *it != '\t') if(*it != ' ' && *it != '\t')

View File

@@ -90,7 +90,7 @@ put(net::const_buffer buffer,
BOOST_ASSERT(!is_done()); BOOST_ASSERT(!is_done());
if (is_done()) if (is_done())
{ {
ec = error::stale_parser; BOOST_BEAST_ASSIGN_EC(ec, error::stale_parser);
return 0; return 0;
} }
auto p = static_cast<char const*>(buffer.data()); auto p = static_cast<char const*>(buffer.data());
@@ -104,7 +104,7 @@ loop:
case state::nothing_yet: case state::nothing_yet:
if(n == 0) if(n == 0)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return 0; return 0;
} }
state_ = state::start_line; state_ = state::start_line;
@@ -123,7 +123,7 @@ loop:
{ {
if(n >= header_limit_) if(n >= header_limit_)
{ {
ec = error::header_limit; BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
goto done; goto done;
} }
if(p + 3 <= p1) if(p + 3 <= p1)
@@ -136,7 +136,7 @@ loop:
n = static_cast<std::size_t>(p1 - p); n = static_cast<std::size_t>(p1 - p);
if(p >= p1) if(p >= p1)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
goto done; goto done;
} }
BOOST_FALLTHROUGH; BOOST_FALLTHROUGH;
@@ -154,7 +154,7 @@ loop:
{ {
if(n >= header_limit_) if(n >= header_limit_)
{ {
ec = error::header_limit; BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
goto done; goto done;
} }
if(p + 3 <= p1) if(p + 3 <= p1)
@@ -239,14 +239,14 @@ put_eof(error_code& ec)
if( state_ == state::start_line || if( state_ == state::start_line ||
state_ == state::fields) state_ == state::fields)
{ {
ec = error::partial_message; BOOST_BEAST_ASSIGN_EC(ec, error::partial_message);
return; return;
} }
if(f_ & (flagContentLength | flagChunked)) if(f_ & (flagContentLength | flagChunked))
{ {
if(state_ != state::complete) if(state_ != state::complete)
{ {
ec = error::partial_message; BOOST_BEAST_ASSIGN_EC(ec, error::partial_message);
return; return;
} }
ec = {}; ec = {};
@@ -272,7 +272,7 @@ maybe_need_more(
n = header_limit_; n = header_limit_;
if(n < skip_ + 4) if(n < skip_ + 4)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
auto const term = auto const term =
@@ -282,10 +282,10 @@ maybe_need_more(
skip_ = n - 3; skip_ = n - 3;
if(skip_ + 4 > header_limit_) if(skip_ + 4 > header_limit_)
{ {
ec = error::header_limit; BOOST_BEAST_ASSIGN_EC(ec, error::header_limit);
return; return;
} }
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
skip_ = 0; skip_ = 0;
@@ -320,18 +320,18 @@ parse_start_line(
return; return;
if(version < 10 || version > 11) if(version < 10 || version > 11)
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
if(p + 2 > last) if(p + 2 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(p[0] != '\r' || p[1] != '\n') if(p[0] != '\r' || p[1] != '\n')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
p += 2; p += 2;
@@ -368,19 +368,19 @@ parse_start_line(
return; return;
if(version < 10 || version > 11) if(version < 10 || version > 11)
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
// SP // SP
if(p + 1 > last) if(p + 1 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(*p++ != ' ') if(*p++ != ' ')
{ {
ec = error::bad_version; BOOST_BEAST_ASSIGN_EC(ec, error::bad_version);
return; return;
} }
@@ -421,13 +421,15 @@ parse_fields(char const*& in,
{ {
if(p + 2 > last) if(p + 2 > last)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(p[0] == '\r') if(p[0] == '\r')
{ {
if(p[1] != '\n') if(p[1] != '\n')
ec = error::bad_line_ending; {
BOOST_BEAST_ASSIGN_EC(ec, error::bad_line_ending);
}
in = p + 2; in = p + 2;
return; return;
} }
@@ -462,7 +464,7 @@ finish_header(error_code& ec, std::true_type)
if(body_limit_.has_value() && if(body_limit_.has_value() &&
len_ > body_limit_) len_ > body_limit_)
{ {
ec = error::body_limit; BOOST_BEAST_ASSIGN_EC(ec, error::body_limit);
return; return;
} }
if(len_ > 0) if(len_ > 0)
@@ -527,7 +529,7 @@ finish_header(error_code& ec, std::false_type)
if(body_limit_.has_value() && if(body_limit_.has_value() &&
len_ > body_limit_) len_ > body_limit_)
{ {
ec = error::body_limit; BOOST_BEAST_ASSIGN_EC(ec, error::body_limit);
return; return;
} }
} }
@@ -591,7 +593,7 @@ parse_body_to_eof(char const*& p,
{ {
if (n > *body_limit_) if (n > *body_limit_)
{ {
ec = error::body_limit; BOOST_BEAST_ASSIGN_EC(ec, error::body_limit);
return; return;
} }
*body_limit_ -= n; *body_limit_ -= n;
@@ -631,7 +633,7 @@ parse_chunk_header(char const*& p0,
{ {
if(n < skip_ + 2) if(n < skip_ + 2)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
if(f_ & flagExpectCRLF) if(f_ & flagExpectCRLF)
@@ -641,7 +643,7 @@ parse_chunk_header(char const*& p0,
// be parsed in one call instead of two. // be parsed in one call instead of two.
if(! parse_crlf(p)) if(! parse_crlf(p))
{ {
ec = error::bad_chunk; BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk);
return; return;
} }
} }
@@ -650,7 +652,7 @@ parse_chunk_header(char const*& p0,
return; return;
if(! eol) if(! eol)
{ {
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
skip_ = n - 1; skip_ = n - 1;
return; return;
} }
@@ -660,7 +662,7 @@ parse_chunk_header(char const*& p0,
std::uint64_t size; std::uint64_t size;
if(! parse_hex(p, size)) if(! parse_hex(p, size))
{ {
ec = error::bad_chunk; BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk);
return; return;
} }
if(size != 0) if(size != 0)
@@ -669,7 +671,7 @@ parse_chunk_header(char const*& p0,
{ {
if (size > *body_limit_) if (size > *body_limit_)
{ {
ec = error::body_limit; BOOST_BEAST_ASSIGN_EC(ec, error::body_limit);
return; return;
} }
*body_limit_ -= size; *body_limit_ -= size;
@@ -680,7 +682,7 @@ parse_chunk_header(char const*& p0,
return; return;
if(p != eol -2 ) if(p != eol -2 )
{ {
ec = error::bad_chunk_extension; BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk_extension);
return; return;
} }
auto const ext = make_string(start, p); auto const ext = make_string(start, p);
@@ -713,7 +715,7 @@ parse_chunk_header(char const*& p0,
{ {
BOOST_ASSERT(n >= 3); BOOST_ASSERT(n >= 3);
skip_ = n - 3; skip_ = n - 3;
ec = error::need_more; BOOST_BEAST_ASSIGN_EC(ec, error::need_more);
return; return;
} }
@@ -723,7 +725,7 @@ parse_chunk_header(char const*& p0,
return; return;
if(p != eol - 2) if(p != eol - 2)
{ {
ec = error::bad_chunk_extension; BOOST_BEAST_ASSIGN_EC(ec, error::bad_chunk_extension);
return; return;
} }
auto const ext = make_string(start, p); auto const ext = make_string(start, p);
@@ -774,7 +776,7 @@ do_field(field f,
if(! validate_list(list)) if(! validate_list(list))
{ {
// VFALCO Should this be a field specific error? // VFALCO Should this be a field specific error?
ec = error::bad_value; BOOST_BEAST_ASSIGN_EC(ec, error::bad_value);
return; return;
} }
for(auto const& s : list) for(auto const& s : list)
@@ -806,12 +808,12 @@ do_field(field f,
{ {
auto bad_content_length = [&ec] auto bad_content_length = [&ec]
{ {
ec = error::bad_content_length; BOOST_BEAST_ASSIGN_EC(ec, error::bad_content_length);
}; };
auto multiple_content_length = [&ec] auto multiple_content_length = [&ec]
{ {
ec = error::multiple_content_length; BOOST_BEAST_ASSIGN_EC(ec, error::multiple_content_length);
}; };
// conflicting field // conflicting field
@@ -861,14 +863,14 @@ do_field(field f,
if(f_ & flagChunked) if(f_ & flagChunked)
{ {
// duplicate // duplicate
ec = error::bad_transfer_encoding; BOOST_BEAST_ASSIGN_EC(ec, error::bad_transfer_encoding);
return; return;
} }
if(f_ & flagContentLength) if(f_ & flagContentLength)
{ {
// conflicting field // conflicting field
ec = error::bad_transfer_encoding; BOOST_BEAST_ASSIGN_EC(ec, error::bad_transfer_encoding);
return; return;
} }

View File

@@ -471,7 +471,7 @@ public:
{ {
if(ec) if(ec)
{ {
ec = make_win32_error(ec); BOOST_BEAST_ASSIGN_EC(ec, make_win32_error(ec));
} }
else if(! ec && ! header_) else if(! ec && ! header_)
{ {
@@ -573,8 +573,8 @@ write_some(
0); 0);
if(! bSuccess) if(! bSuccess)
{ {
ec = detail::make_win32_error( BOOST_BEAST_ASSIGN_EC(ec, detail::make_win32_error(
boost::winapi::GetLastError()); boost::winapi::GetLastError()));
return 0; return 0;
} }
w.pos_ += nNumberOfBytesToWrite; w.pos_ += nNumberOfBytesToWrite;

View File

@@ -238,7 +238,9 @@ public:
} }
bytes_transferred_ += bytes_transferred; bytes_transferred_ += bytes_transferred;
if (!ec && st_.cancelled() != net::cancellation_type::none) if (!ec && st_.cancelled() != net::cancellation_type::none)
ec = net::error::operation_aborted; {
BOOST_BEAST_ASSIGN_EC(ec, net::error::operation_aborted);
}
if(ec) if(ec)
goto upcall; goto upcall;
if(Predicate{}(sr_)) if(Predicate{}(sr_))

View File

@@ -326,7 +326,7 @@ doParams(z_params& zs, int level, Strategy strategy, error_code& ec)
level = 6; level = 6;
if(level < 0 || level > 9) if(level < 0 || level > 9)
{ {
ec = error::stream_error; BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
return; return;
} }
func = get_config(level_).func; func = get_config(level_).func;
@@ -366,12 +366,12 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
if(zs.next_out == nullptr || if(zs.next_out == nullptr ||
(status_ == FINISH_STATE && flush != Flush::finish)) (status_ == FINISH_STATE && flush != Flush::finish))
{ {
ec = error::stream_error; BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
return; return;
} }
if(zs.avail_out == 0) if(zs.avail_out == 0)
{ {
ec = error::need_buffers; BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
return; return;
} }
@@ -406,14 +406,14 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
* flushes. For repeated and useless calls with Flush::finish, we keep * flushes. For repeated and useless calls with Flush::finish, we keep
* returning Z_STREAM_END instead of Z_BUF_ERROR. * returning Z_STREAM_END instead of Z_BUF_ERROR.
*/ */
ec = error::need_buffers; BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
return; return;
} }
// User must not provide more input after the first FINISH: // User must not provide more input after the first FINISH:
if(status_ == FINISH_STATE && zs.avail_in != 0) if(status_ == FINISH_STATE && zs.avail_in != 0)
{ {
ec = error::need_buffers; BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
return; return;
} }
@@ -493,7 +493,7 @@ doWrite(z_params& zs, boost::optional<Flush> flush, error_code& ec)
if(flush == Flush::finish) if(flush == Flush::finish)
{ {
ec = error::end_of_stream; BOOST_BEAST_ASSIGN_EC(ec, error::end_of_stream);
return; return;
} }
} }
@@ -505,7 +505,7 @@ doDictionary(Byte const* dict, uInt dictLength, error_code& ec)
{ {
if(lookahead_) if(lookahead_)
{ {
ec = error::stream_error; BOOST_BEAST_ASSIGN_EC(ec, error::stream_error);
return; return;
} }
@@ -561,7 +561,7 @@ doPrime(int bits, int value, error_code& ec)
if((Byte *)(sym_buf_) < pending_out_ + ((Buf_size + 7) >> 3)) if((Byte *)(sym_buf_) < pending_out_ + ((Buf_size + 7) >> 3))
{ {
ec = error::need_buffers; BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
return; return;
} }

View File

@@ -113,12 +113,14 @@ doWrite(z_params& zs, Flush flush, error_code& ec)
if(((! r.in.used() && ! r.out.used()) || if(((! r.in.used() && ! r.out.used()) ||
flush == Flush::finish) && ! ec) flush == Flush::finish) && ! ec)
ec = error::need_buffers; {
BOOST_BEAST_ASSIGN_EC(ec, error::need_buffers);
}
}; };
auto const err = auto const err =
[&](error e) [&](error e)
{ {
ec = e; BOOST_BEAST_ASSIGN_EC(ec, e);
mode_ = BAD; mode_ = BAD;
}; };
@@ -516,8 +518,10 @@ doWrite(z_params& zs, Flush flush, error_code& ec)
BOOST_FALLTHROUGH; BOOST_FALLTHROUGH;
case DONE: case DONE:
ec = error::end_of_stream; {
BOOST_BEAST_ASSIGN_EC(ec, error::end_of_stream);
return done(); return done();
}
case BAD: case BAD:
return done(); return done();
@@ -666,13 +670,13 @@ inflate_table(
left -= count[len]; left -= count[len];
if (left < 0) if (left < 0)
{ {
ec = error::over_subscribed_length; BOOST_BEAST_ASSIGN_EC(ec, error::over_subscribed_length);
return; return;
} }
} }
if (left > 0 && (type == build::codes || max != 1)) if (left > 0 && (type == build::codes || max != 1))
{ {
ec = error::incomplete_length_set; BOOST_BEAST_ASSIGN_EC(ec, error::incomplete_length_set);
return; return;
} }
@@ -1037,7 +1041,7 @@ inflate_fast(ranges& r, error_code& ec)
#ifdef INFLATE_STRICT #ifdef INFLATE_STRICT
if(dist > dmax_) if(dist > dmax_)
{ {
ec = error::invalid_distance; BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance);
mode_ = BAD; mode_ = BAD;
break; break;
} }
@@ -1051,7 +1055,7 @@ inflate_fast(ranges& r, error_code& ec)
op = dist - op; // distance back in window op = dist - op; // distance back in window
if(op > w_.size()) if(op > w_.size())
{ {
ec = error::invalid_distance; BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance);
mode_ = BAD; mode_ = BAD;
break; break;
} }
@@ -1078,7 +1082,7 @@ inflate_fast(ranges& r, error_code& ec)
} }
else else
{ {
ec = error::invalid_distance_code; BOOST_BEAST_ASSIGN_EC(ec, error::invalid_distance_code);
mode_ = BAD; mode_ = BAD;
break; break;
} }
@@ -1097,7 +1101,7 @@ inflate_fast(ranges& r, error_code& ec)
} }
else else
{ {
ec = error::invalid_literal_length; BOOST_BEAST_ASSIGN_EC(ec, error::invalid_literal_length);
mode_ = BAD; mode_ = BAD;
break; break;
} }

View File

@@ -369,8 +369,10 @@ write(void const* data,
&state_, hooks(), &state_, hooks(),
static_cast<const char*>(data), size); static_cast<const char*>(data), size);
if(! ec) if(! ec)
ec = detail::make_nodejs_error( {
static_cast<int>(state_.http_errno)); BOOST_BEAST_ASSIGN_EC(ec, detail::make_nodejs_error(
static_cast<int>(state_.http_errno)));
}
if(ec) if(ec)
return 0; return 0;
return n; return n;
@@ -384,8 +386,10 @@ write_eof(error_code& ec)
ec_ = &ec; ec_ = &ec;
http_parser_execute(&state_, hooks(), nullptr, 0); http_parser_execute(&state_, hooks(), nullptr, 0);
if(! ec) if(! ec)
ec = detail::make_nodejs_error( {
static_cast<int>(state_.http_errno)); BOOST_BEAST_ASSIGN_EC(ec, detail::make_nodejs_error(
static_cast<int>(state_.http_errno)));
}
} }
template<class Derived> template<class Derived>