simple_network_handler 1.3.0
simple_network_handler: ^1.3.0 copied to clipboard
A package for handling network errors with error registry and interceptors. Supports Dio and Supabase.
1.3.0 #
- feat: add
TransportFailuremarker mixin on the sharedFailurebase. Mix it onto any failure representing a transport-level problem (offline / timeout / unreachable) so UIs and observers can special-case connectivity once, regardless of feature. Because it lives on the shared base, it is available to both the Dio (REST) and Supabase variants. - feat:
SupabaseErrorRegistrygains first-class transport classification —bool isTransportError(Object error)(default coversTimeoutExceptionandSocketException;SocketExceptionmatched by runtime type name to avoid adart:ioimport so web builds keep compiling) andFailure get transportError(defaults togenericError; override to return your localized offline failure). Wired intosafeCall's general-exception path. - feat: add
Either<Failure, T>.mapBusiness(ifBusinessError, onData)extension — a transport-aware fold that letsTransportFailures pass through unchanged while substituting a feature-specific failure for any otherLeft. Replaces thefold((_) => Left(FeatureFailure()), ...)pattern that discarded transport classification. - note: fully backward compatible. Existing consumers compile and behave identically without opting in — the default
transportErrorisgenericError, and the new transport check runs only AFTER the existinghandleRealtimeErrorconsultation, so registries that classify transport errors via the realtime hook keep working unchanged. - migration hint: replace
result.fold((_) => Left(FeatureFailure()), (data) => Right(...))withresult.mapBusiness(const FeatureFailure(), (data) => Right(...)), and overridetransportErroron your registry to return a failure that mixes inTransportFailure.
1.2.0 #
- feat: add RefreshTokenInterceptor with automatic token refresh, single-flight queuing of concurrent 401s and request replay
- feat: add TokenStore interface and RefreshRequest spec executed on a separate bare Dio instance
- docs: document the required interceptor order with ErrorMappingInterceptor
1.1.1 #
- fix:
SupabaseNetworkHandlernow resolvesAuthExceptions against the auth registry by semanticcode(e.g.email_not_confirmed,invalid_credentials), falling back tostatusCodeand thenmessage. Previously onlystatusCode/messagewere checked, so registries keyed by error codes never matched.
1.1.0 #
- feat: add Supabase API support with
SupabaseNetworkHandlerandSupabaseErrorRegistry - feat: add Supabase-specific failure classes (AuthFailure, PostgrestFailure, StorageFailure, etc.)
- feat: add separate import for Supabase:
import 'package:simple_network_handler/simple_network_handler_supabase.dart' - feat: add example Supabase error registry and repository implementation
1.0.4 #
- feat: change general error to accept types and provide access to the exception itself
- feat: add logging functionality
1.0.3 #
- feat: add handling of custom exceptions
1.0.2 #
- chore: update readme
1.0.1 #
- chore: update readme
- feat: add example app that showcases an advanced use case
1.0.0 #
- feat: initial release of Simple Network Handler