captureException static method
void
captureException(
- dynamic exception,
)
Implementation
static void captureException(
dynamic exception, ExceptionExtraAttributes? extraAttributes) async {
final stackTrace = _extractStackTrace(exception);
final errorData = <String, dynamic>{
'clientVersion': Vigil.version,
'error': {
'name': exception.runtimeType.toString(),
'message': exception.toString(),
'stack': stackTrace,
},
'reportedAt': DateTime.now().toUtc().toIso8601String(),
};
final tags = extraAttributes?.tags;
if (tags != null && tags.isNotEmpty) {
errorData["tags"] = tags;
}
final context = extraAttributes?.context;
if (context != null && context.isNotEmpty) {
errorData["context"] = context;
}
try {
await ApiService.makeApiCall(Vigil.instanceUrl!,
RouteConstants.ERROR_MONITORING, errorData, Vigil.apiKey);
LogService.logger.i('Vigil exception record added successfully');
} catch (e) {
LogService.logger.i("Error while creating exception log: $e");
}
}