init method

Future<void> init({
  1. String? storageKey,
  2. HummErrorStorage? errorStorage,
  3. List<HummErrorTracker>? trackers,
  4. int? logSize,
  5. ErrorDisplayCallback? errorDisplayCallback,
  6. ErrorTranslationCallback? errorTranslationCallback,
  7. bool shouldDisplayErrorCallback(
    1. dynamic error,
    2. StackTrace stackTrace
    )?,
  8. String? defaultErrorMessage,
})

Initialize the error handler with basic configuration

Implementation

Future<void> init({
  String? storageKey,
  HummErrorStorage? errorStorage,
  List<HummErrorTracker>? trackers,
  int? logSize,
  ErrorDisplayCallback? errorDisplayCallback,
  ErrorTranslationCallback? errorTranslationCallback,
  bool Function(dynamic error, StackTrace stackTrace)? shouldDisplayErrorCallback,
  String? defaultErrorMessage,
}) async {
  this.errorStorage = errorStorage ?? await HummErrorStorageImpl.create(storageKey: storageKey ?? StorageKey.key);

  // Set log size if provided
  if (logSize != null) {
    this.logSize = logSize;
  }

  if (trackers != null && trackers.isNotEmpty) {
    _trackers.addAll(trackers);
  }

  _errorDisplayCallback = errorDisplayCallback;
  _errorTranslationCallback = errorTranslationCallback;
  _shouldDisplayErrorCallback = shouldDisplayErrorCallback;

  if (defaultErrorMessage != null) {
    _defaultErrorMessage = defaultErrorMessage;
  }
}