guardCapture<T> function

T? guardCapture<T>(
  1. T body()
)

Runs body and swallows any error it throws.

Capture code must never break the host app's request: an inspector that turns a successful request into a failure is worse than no inspector. Every adapter wraps its bookkeeping in this guard.

Implementation

T? guardCapture<T>(T Function() body) {
  try {
    return body();
  } catch (e, st) {
    if (kDebugMode) {
      debugPrint('[Interceptly] capture failed (request unaffected): $e\n$st');
    }
    return null;
  }
}