captureException function

Future<void> captureException(
  1. String? message, {
  2. String? query,
  3. Map<String, dynamic>? variables,
  4. dynamic response,
  5. dynamic error,
})

Used to capture User Exceptions and logged to BeWell Sentry

These include exceptions like: 'Error while fetching user feed' Check exception_strings.dart for more examples of these exceptions.

@params

  • message: Reported as issue title
  • query and variables: The query/mutation with variables that resulted into the exception
  • response: Response received
  • error: exception string

Implementation

Future<void> captureException(
  String? message, {
  String? query,
  Map<String, dynamic>? variables,
  dynamic response,
  dynamic error,
}) async {
  final Map<String, dynamic> stackTrace = <String, dynamic>{
    'query': query,
    'variables': variables,
    'response': response,
    'error': error
  };

  /// Adds the stackTrace as a breadcrumb
  Sentry.addBreadcrumb(Breadcrumb(
      message: 'Stacktrace for: $message',
      data: stackTrace,
      timestamp: DateTime.now()));
  await Sentry.captureException(UserException(message));
}