mudular code ready to fork 2

This commit is contained in:
gitea
2025-11-08 12:54:49 +01:00
parent 8c6bf598f5
commit 3debb6ad7d
13 changed files with 522 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/// Barrel file for all exceptions.
///
/// Import this file to get access to all exception classes.
export 'firebase_exception.dart' show FirebaseServiceException;
export 'immich_exception.dart';
export 'invalid_environment_exception.dart';
export 'nostr_exception.dart';
export 'session_exception.dart';
export 'sync_exception.dart';
@@ -0,0 +1,15 @@
/// Exception thrown when Firebase service operations fail.
///
/// Note: This is different from Firebase SDK's FirebaseException.
/// This exception is used for our FirebaseService wrapper.
class FirebaseServiceException implements Exception {
/// Error message.
final String message;
/// Creates a [FirebaseServiceException] with the provided message.
FirebaseServiceException(this.message);
@override
String toString() => 'FirebaseServiceException: $message';
}
+20
View File
@@ -0,0 +1,20 @@
/// Exception thrown when Immich API operations fail.
class ImmichException implements Exception {
/// Error message.
final String message;
/// HTTP status code if available.
final int? statusCode;
/// Creates an [ImmichException] with the provided message.
ImmichException(this.message, [this.statusCode]);
@override
String toString() {
if (statusCode != null) {
return 'ImmichException: $message (Status: $statusCode)';
}
return 'ImmichException: $message';
}
}
@@ -0,0 +1,15 @@
/// Exception thrown when an invalid environment is provided to [ConfigLoader].
class InvalidEnvironmentException implements Exception {
/// The invalid environment that was provided.
final String environment;
/// Creates an [InvalidEnvironmentException] with the provided environment.
InvalidEnvironmentException(this.environment);
@override
String toString() {
return 'InvalidEnvironmentException: Invalid environment "$environment". '
'Valid environments are: dev, prod';
}
}
+12
View File
@@ -0,0 +1,12 @@
/// Exception thrown when Nostr operations fail.
class NostrException implements Exception {
/// Error message.
final String message;
/// Creates a [NostrException] with the provided message.
NostrException(this.message);
@override
String toString() => 'NostrException: $message';
}
@@ -0,0 +1,12 @@
/// Exception thrown when session operations fail.
class SessionException implements Exception {
/// Error message.
final String message;
/// Creates a [SessionException] with the provided message.
SessionException(this.message);
@override
String toString() => 'SessionException: $message';
}
+12
View File
@@ -0,0 +1,12 @@
/// Exception thrown when sync operations fail.
class SyncException implements Exception {
/// Error message.
final String message;
/// Creates a [SyncException] with the provided message.
SyncException(this.message);
@override
String toString() => 'SyncException: $message';
}