Skip to content

Commit

Permalink
fix(github_repository): Catch AppException with safeRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
trm11tkr committed Apr 11, 2024
1 parent 23daa41 commit a00d21e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cores_core/exception.dart';
import 'package:cores_core/src/pagination/model/paging_data.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

Expand Down Expand Up @@ -62,7 +63,7 @@ extension AsyncValueErrorHandling<T> on AsyncValue<T> {
Future<AsyncValue<T>> guardPlus(Future<T> Function() future) async {
try {
return AsyncValue.data(await future());
} on Exception catch (err, stack) {
} on AppException catch (err, stack) {
return AsyncValue<T>.error(err, stack).copyWithPrevious(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ Future<GitHubRepositoryResult> listOrganizationRepositories(
int perPage = 30,
}) async {
final dio = ref.watch(dioProvider);
final response = await dio
.get<ListJson>('/orgs/yumemi-inc/repos?page=$page&per_page=$perPage');
final response = await dio.safeRequest(
request: () => dio
.get<ListJson>('/orgs/yumemi-inc/repos?page=$page&per_page=$perPage'),
);
final items = response.data?.parseList(GitHubRepository.fromJson) ?? [];
return GitHubRepositoryResult(
items: items,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a00d21e

Please sign in to comment.