Skip to content

Commit

Permalink
feat: Add ignoreNoProfilePictureError to Ignore Errors in apptive_g…
Browse files Browse the repository at this point in the history
…rid_error_reporting (#30)
  • Loading branch information
Anton Borries authored Dec 5, 2023
1 parent 59a2ea2 commit 6d29949
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,16 @@ class ProfilePicture extends StatelessWidget {
);
}
}

/// Ignoring Function useful for using `apptive_grid_error_reporting`
/// If this is used inside the `ignoreError` callback of `ApptiveGridErrorReporting`
/// this will not report FlutterError that are reported when requesting ProfilePicture from Users that do not have a Profile Picture set
bool ignoreNoProfilePictureError(dynamic error) {
if (error is NetworkImageLoadException &&
error.uri.host ==
'apptiveavatarupload-apptiveavataruploadbucket-17hw58ak4gvs6.s3.eu-central-1.amazonaws.com' &&
error.statusCode == 403) {
return true;
}
return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,36 @@ void main() {

expect(find.text('FL'), findsOneWidget);
});

group('Ignore No Profile Picture Error', () {
const codeToIgnore = 403;
const hostToIgnore =
'apptiveavatarupload-apptiveavataruploadbucket-17hw58ak4gvs6.s3.eu-central-1.amazonaws.com';
test('403 with host gets ignored', () async {
final exception = NetworkImageLoadException(
statusCode: codeToIgnore,
uri: Uri(host: hostToIgnore),
);

expect(ignoreNoProfilePictureError(exception), isTrue);
});

test('Different status code is not ignored', () async {
final exception = NetworkImageLoadException(
statusCode: codeToIgnore + 1,
uri: Uri(host: hostToIgnore),
);

expect(ignoreNoProfilePictureError(exception), isFalse);
});

test('Different host is not ignored', () async {
final exception = NetworkImageLoadException(
statusCode: codeToIgnore,
uri: Uri(host: 'different'),
);

expect(ignoreNoProfilePictureError(exception), isFalse);
});
});
}

0 comments on commit 6d29949

Please sign in to comment.