This commit is contained in:
Juan Gilsanz Polo 2023-11-24 00:30:57 +01:00
parent 791182d9c4
commit d43f759662
2 changed files with 26 additions and 8 deletions

View file

@ -6,7 +6,7 @@ import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:adguard_home_manager/models/server.dart'; import 'package:adguard_home_manager/models/server.dart';
enum ExceptionType { socket, timeout, handshake, unknown } enum ExceptionType { socket, timeout, handshake, http, unknown }
class HttpResponse { class HttpResponse {
final bool successful; final bool successful;
@ -73,8 +73,14 @@ class HttpRequestClient {
statusCode: null, statusCode: null,
exception: ExceptionType.handshake exception: ExceptionType.handshake
); );
} catch (e, stackTrace) { } on HttpException {
Sentry.captureException(e, stackTrace: stackTrace); return const HttpResponse(
successful: false,
body: null,
statusCode: null,
exception: ExceptionType.http
);
} catch (e) {
return const HttpResponse( return const HttpResponse(
successful: false, successful: false,
body: null, body: null,
@ -123,6 +129,13 @@ class HttpRequestClient {
statusCode: null, statusCode: null,
exception: ExceptionType.timeout exception: ExceptionType.timeout
); );
} on HttpException {
return const HttpResponse(
successful: false,
body: null,
statusCode: null,
exception: ExceptionType.http
);
} on HandshakeException { } on HandshakeException {
return const HttpResponse( return const HttpResponse(
successful: false, successful: false,
@ -130,8 +143,7 @@ class HttpRequestClient {
statusCode: null, statusCode: null,
exception: ExceptionType.handshake exception: ExceptionType.handshake
); );
} catch (e, stackTrace) { } catch (e) {
Sentry.captureException(e, stackTrace: stackTrace);
return const HttpResponse( return const HttpResponse(
successful: false, successful: false,
body: null, body: null,
@ -180,6 +192,13 @@ class HttpRequestClient {
statusCode: null, statusCode: null,
exception: ExceptionType.timeout exception: ExceptionType.timeout
); );
} on HttpException {
return const HttpResponse(
successful: false,
body: null,
statusCode: null,
exception: ExceptionType.http
);
} on HandshakeException { } on HandshakeException {
return const HttpResponse( return const HttpResponse(
successful: false, successful: false,
@ -187,8 +206,7 @@ class HttpRequestClient {
statusCode: null, statusCode: null,
exception: ExceptionType.handshake exception: ExceptionType.handshake
); );
} catch (e, stackTrace) { } catch (e) {
Sentry.captureException(e, stackTrace: stackTrace);
return const HttpResponse( return const HttpResponse(
successful: false, successful: false,
body: null, body: null,

View file

@ -265,7 +265,7 @@ class ServersProvider with ChangeNotifier {
if (data.currentVersion == data.newVersion) { if (data.currentVersion == data.newVersion) {
final gitHubResult = await ExternalRequests.getReleaseData(releaseTag: data.newVersion ?? data.currentVersion); final gitHubResult = await ExternalRequests.getReleaseData(releaseTag: data.newVersion ?? data.currentVersion);
if (gitHubResult.successful == true) { if (gitHubResult.successful == true) {
data.changelog = gitHubResult.content; data.changelog = (gitHubResult.content as GitHubRelease).body;
} }
setUpdateAvailableData(data); setUpdateAvailableData(data);
timer.cancel(); timer.cancel();