ErrorRecoveryConfig class
Configuration for error handling and recovery.
Example:
Locus.setErrorHandler(ErrorRecoveryConfig(
onError: (error, context) {
analytics.logError(error);
return error.suggestedRecovery ?? RecoveryAction.retry;
},
maxRetries: 3,
retryDelay: Duration(seconds: 5),
retryBackoff: 2.0,
));
Constructors
-
ErrorRecoveryConfig({RecoveryAction onError(LocusError error, ErrorContext context)?, void onResolved(LocusError error, int attemptsTaken)?, void onExhausted(LocusError error)?, int maxRetries = 3, Duration retryDelay = const Duration(seconds: 5), double retryBackoff = 2.0, Duration maxRetryDelay = const Duration(minutes: 5), bool autoRestart = true, Set<
LocusErrorType> autoRetryTypes = const {LocusErrorType.locationTimeout, LocusErrorType.networkError, LocusErrorType.serviceDisconnected}, Set<LocusErrorType> ignoreTypes = const {}, bool logErrors = true}) -
Creates an error recovery configuration.
const
Properties
- autoRestart → bool
-
Whether to automatically restart tracking after certain errors.
final
-
autoRetryTypes
→ Set<
LocusErrorType> -
Error types to automatically retry.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
ignoreTypes
→ Set<
LocusErrorType> -
Error types to ignore (not propagate to listeners).
final
- logErrors → bool
-
Whether to log errors to the console.
final
- maxRetries → int
-
Maximum number of retry attempts.
final
- maxRetryDelay → Duration
-
Maximum delay between retries.
final
- onError → RecoveryAction Function(LocusError error, ErrorContext context)?
-
Callback to handle errors and determine recovery action.
final
- onExhausted → void Function(LocusError error)?
-
Callback when max retries exhausted.
final
- onResolved → void Function(LocusError error, int attemptsTaken)?
-
Callback when an error is resolved (after successful retry).
final
- retryBackoff → double
-
Backoff multiplier for successive retries.
final
- retryDelay → Duration
-
Initial delay between retries.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{RecoveryAction onError(LocusError, ErrorContext)?, void onResolved(LocusError, int)?, void onExhausted(LocusError)?, int? maxRetries, Duration? retryDelay, double? retryBackoff, Duration? maxRetryDelay, bool? autoRestart, Set< LocusErrorType> ? autoRetryTypes, Set<LocusErrorType> ? ignoreTypes, bool? logErrors}) → ErrorRecoveryConfig - Creates a copy with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → JsonMap - Converts to a JSON-serializable map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- aggressive → const ErrorRecoveryConfig
- Aggressive retry - more attempts, shorter delays.
- conservative → const ErrorRecoveryConfig
- Conservative - fewer retries, longer delays.
- defaults → const ErrorRecoveryConfig
- Default configuration with sensible defaults.