File tree Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 2
2
#include " aur/client.hh"
3
3
4
4
#include < curl/curl.h>
5
- #include < fcntl.h>
6
5
#include < systemd/sd-event.h>
7
6
#include < unistd.h>
8
7
@@ -189,16 +188,12 @@ class TypedResponseHandler : public ResponseHandler {
189
188
: ResponseHandler(client), callback_(std::move(callback)) {}
190
189
191
190
protected:
192
- absl::StatusOr<ResponseT> MakeResponse () {
193
- return ResponseT::Parse (std::move (body));
194
- }
195
-
196
191
int RunCallback (absl::Status status) override {
197
- if (status.ok ()) {
198
- return std::move (callback_)(MakeResponse ());
199
- } else {
192
+ if (!status.ok ()) {
200
193
return std::move (callback_)(std::move (status));
201
194
}
195
+
196
+ return std::move (callback_)(ResponseT::Parse (std::move (body)));
202
197
}
203
198
204
199
private:
Original file line number Diff line number Diff line change 1
1
// SPDX-License-Identifier: MIT
2
2
#include " aur/response.hh"
3
3
4
- #include " absl/base/no_destructor.h"
5
4
#include " aur/json_internal.hh"
6
5
7
6
using nlohmann::json;
@@ -10,9 +9,9 @@ namespace aur {
10
9
11
10
absl::StatusOr<RpcResponse> RpcResponse::Parse (std::string_view bytes) {
12
11
try {
13
- json j = json::parse (bytes);
14
- if (auto iter = j.find (" error" ); iter != j.end ()) {
15
- return absl::InvalidArgumentError (iter->get <std::string >());
12
+ const json j = json::parse (bytes);
13
+ if (const auto iter = j.find (" error" ); iter != j.end ()) {
14
+ return absl::InvalidArgumentError (iter->get <std::string_view >());
16
15
}
17
16
18
17
return RpcResponse (j[" results" ].get <std::vector<Package>>());
Original file line number Diff line number Diff line change 2
2
#ifndef AUR_RESPONSE_HH_
3
3
#define AUR_RESPONSE_HH_
4
4
5
- #include " absl/status/status.h"
5
+ #include < string>
6
+ #include < string_view>
7
+ #include < vector>
8
+
6
9
#include " absl/status/statusor.h"
7
10
#include " aur/package.hh"
8
11
You can’t perform that action at this time.
0 commit comments