Skip to content

Commit

Permalink
Merge pull request #2 from a-givertzman/ApiRequest-fetch-fold-fix
Browse files Browse the repository at this point in the history
ApiReply | Checked error firstly in result
  • Loading branch information
Minyewoo authored Oct 9, 2023
2 parents 874f106 + 01a8cf1 commit a613a5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 9 additions & 12 deletions lib/src/request/api_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ class ApiRequest {
return result.fold(
onData: (_) {
return _read(socket).then((result) {
return result.fold(
onData: (bytes) {
return Result<ApiReply>(
data: ApiReply.fromJson(
utf8.decode(bytes),
),
);
},
onError: (err) {
return Result<ApiReply>(error: err);
},
);
if (result.hasError) {
return Result<ApiReply>(error: result.error);
} else {
return Result(
data: ApiReply.fromJson(
utf8.decode(result.data),
),
);
}
});
},
onError: (err) {
Expand Down
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies:
git:
url: https://github.com/a-givertzman/hmi_core.git
ref: master # branch name
logging: ^1.1.1
uuid: ^3.0.7

dev_dependencies:
flutter_test:
Expand All @@ -32,8 +34,8 @@ dev_dependencies:

# The following section is specific to Flutter packages.
flutter:
assets:
- assets/test/
# assets:
# - assets/test/
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
Expand Down

0 comments on commit a613a5c

Please sign in to comment.