Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sentry not report exceptions from the HTTP client #525

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/api/concrexit_api_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ class LoggingClient extends oauth2.Client {

@override
Future<StreamedResponse> send(BaseRequest request) async {
final response = await super.send(request);
StreamedResponse response;
try {
response = await super.send(request);
} catch (e) {
if (kDebugMode) {
print('url: ${request.url}, failed: $e');
}
rethrow;
}
if (kDebugMode) {
print('url: ${request.url}, response code: ${response.statusCode}');
}
Expand Down
11 changes: 7 additions & 4 deletions lib/blocs/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ class AuthCubit extends Cubit<AuthState> {
),
);
},
httpClient: SentryHttpClient(failedRequestStatusCodes: [
SentryStatusCode(400),
SentryStatusCode.range(405, 499),
]),
httpClient: SentryHttpClient(
failedRequestStatusCodes: [
SentryStatusCode(400),
SentryStatusCode.range(405, 499),
],
captureFailedRequests: false,
),
),
config: apiConfig,
onLogOut: logOut,
Expand Down
17 changes: 11 additions & 6 deletions lib/blocs/list_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ abstract class ListCubit<F, T, S> extends Cubit<S> {
List<Future<List<T>>> futuresUp = [];
List<Future<List<T>>> futuresDown = [];
for (final source in sources) {
source._nextOffsetUp = 0;
source._nextOffsetDown = 0;
source.isDoneUp = false;
source.isDoneDown = false;
try {
source._nextOffsetUp = 0;
source._nextOffsetDown = 0;
source.isDoneUp = false;
source.isDoneDown = false;
futuresUp.add(source.moreUp());
futuresDown.add(source.moreDown());
} on ApiException catch (exception) {
Expand All @@ -115,8 +115,13 @@ abstract class ListCubit<F, T, S> extends Cubit<S> {
cleanupOldState();
List<List<T>> resultsUp = [];
List<List<T>> resultsDown = [];
resultsUp = await Future.wait(futuresUp);
resultsDown = await Future.wait(futuresDown);
try {
resultsUp = await Future.wait(futuresUp);
resultsDown = await Future.wait(futuresDown);
} on ApiException catch (exception) {
safeEmit(failure(exception.message));
return;
}

// Discard result if _searchQuery has
// changed since the request was made.
Expand Down
Loading