Skip to content

Commit ca94771

Browse files
committed
🎉 Add AppwriteException to offline Exception handling
1 parent d9bc258 commit ca94771

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [0.0.4] - 2024-12-08
2+
3+
### Improvements
4+
- Add AppwriteException to offline Exception handling.
5+
16
## [0.0.3] - 2024-12-08
27

38
### Improvements

lib/adapters/appwrite.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,23 @@ mixin AppwriteAdapter<T extends DataModel<T>> on RemoteAdapter<T> {
344344
}
345345
}
346346

347+
@override
348+
bool isOfflineError(Object? error) {
349+
final commonExceptions = [
350+
// timeouts via http's `connectionTimeout` are also socket exceptions
351+
'SocketException',
352+
'HttpException',
353+
'HandshakeException',
354+
'TimeoutException',
355+
];
356+
357+
// we check exceptions with strings to avoid importing `dart:io`
358+
final err = error is AppwriteException
359+
? error.message ?? error.toString()
360+
: error.runtimeType.toString();
361+
return commonExceptions.any(err.contains);
362+
}
363+
347364
/// Parses permission rules from query parameters
348365
///
349366
/// Supported permission types:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: appwrite_offline
22
description: "A Flutter Data adapter for Appwrite that provides offline support, real-time updates, and seamless integration with Flutter Data's powerful features."
3-
version: 0.0.3
3+
version: 0.0.4
44
homepage: https://github.com/cybroidtech/appwrite_offline
55
repository: https://github.com/cybroidtech/appwrite_offline
66
issue_tracker: https://github.com/cybroidtech/appwrite_offline/issues

0 commit comments

Comments
 (0)