Browse Source

neon,neon_notes: Catch generic API exceptions

pull/418/head
jld3103 2 years ago
parent
commit
279fca0d2a
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 2
      packages/neon/neon/lib/src/blocs/user_statuses.dart
  2. 2
      packages/neon/neon/lib/src/utils/request_manager.dart
  3. 2
      packages/neon/neon/lib/src/widgets/exception.dart
  4. 2
      packages/neon/neon_notes/lib/utils/exception_handler.dart

2
packages/neon/neon/lib/src/blocs/user_statuses.dart

@ -63,7 +63,7 @@ class UserStatusesBloc extends InteractiveBloc implements UserStatusesBlocEvents
_updateStatus(username, Result.success(data));
} catch (e, s) {
if (e is NextcloudApiException && (e.statusCode == 404 || e.statusCode == 204)) {
if (e is DynamiteApiException && (e.statusCode == 404 || e.statusCode == 204)) {
_updateStatus(username, Result.success(null));
return;
}

2
packages/neon/neon/lib/src/utils/request_manager.dart

@ -95,7 +95,7 @@ class RequestManager {
} catch (e, s) {
debugPrint(e.toString());
debugPrint(s.toString());
if (e is NextcloudApiException && e.statusCode >= 500 && retries < 3) {
if (e is DynamiteApiException && e.statusCode >= 500 && retries < 3) {
debugPrint('Retrying...');
await _wrap(
clientID,

2
packages/neon/neon/lib/src/widgets/exception.dart

@ -127,7 +127,7 @@ class NeonException extends StatelessWidget {
);
}
if (exception is NextcloudApiException) {
if (exception is DynamiteApiException) {
if (exception.statusCode == 401) {
return _ExceptionDetails(
text: AppLocalizations.of(context).errorCredentialsForAccountNoLongerMatch,

2
packages/neon/neon_notes/lib/utils/exception_handler.dart

@ -1,7 +1,7 @@
part of '../neon_notes.dart';
void handleNotesException(final BuildContext context, final Object error) {
if (error is NextcloudApiException && error.statusCode == 412) {
if (error is DynamiteApiException && error.statusCode == 412) {
NeonException.showSnackbar(context, AppLocalizations.of(context).errorChangedOnServer);
} else {
NeonException.showSnackbar(context, error);

Loading…
Cancel
Save