Skip to content

Commit c9b838b

Browse files
committed
use coke::STATE_SUCCESS rather than 0
1 parent f797712 commit c9b838b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

example/ex002-http_get.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ coke::Task<> http_get(const std::string &url) {
1414
coke::HttpClient cli;
1515
coke::HttpResult res = co_await cli.request(url);
1616

17-
if (res.state == 0) {
17+
if (res.state == coke::STATE_SUCCESS) {
1818
coke::HttpResponse &resp = res.resp;
1919

2020
std::cout << resp.get_http_version() << ' '

example/ex004-word_count.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ coke::Task<> word_count(const std::string &fn) {
3333
while (true) {
3434
res = co_await coke::pread(fd, buf, BUF_SIZE, offset);
3535

36-
if (res.state != 0 || res.nbytes == 0)
36+
if (res.state != coke::STATE_SUCCESS || res.nbytes == 0)
3737
break;
3838

3939
const unsigned char *end = buf + res.nbytes;
@@ -52,14 +52,14 @@ coke::Task<> word_count(const std::string &fn) {
5252
offset += res.nbytes;
5353
}
5454

55-
if (res.state == 0) {
55+
if (res.state == coke::STATE_SUCCESS) {
5656
std::cout << "Chars: " << chars << "\n"
5757
<< "Words: " << words << "\n"
5858
<< "Lines: " << lines << std::endl;
5959
}
6060
else {
61-
std::cerr << "ERROR: state:" << res.state
62-
<< " error:" << res.error << std::endl;
61+
std::cerr << "ERROR: state:" << res.state << " error:" << res.error << std::endl;
62+
std::cerr << coke::get_error_string(res.state, res.error) << std::endl;
6363
}
6464

6565
close(fd);

0 commit comments

Comments
 (0)