@@ -32,7 +32,8 @@ class AppDependencies {
3232 static AppDependencies get instance => _instance;
3333
3434 bool _isInitialized = false ;
35- Exception ? _initializationError;
35+ Object ? _initializationError;
36+ StackTrace ? _initializationStackTrace;
3637 final _log = Logger ('AppDependencies' );
3738
3839 // --- Late-initialized fields for all dependencies ---
@@ -67,7 +68,7 @@ class AppDependencies {
6768 Future <void > init () async {
6869 // If initialization previously failed, re-throw the original error.
6970 if (_initializationError != null ) {
70- throw _initializationError! ;
71+ return Future . error ( _initializationError! , _initializationStackTrace) ;
7172 }
7273
7374 if (_isInitialized) return ;
@@ -200,9 +201,10 @@ class AppDependencies {
200201
201202 _isInitialized = true ;
202203 _log.info ('Application dependencies initialized successfully.' );
203- } on Exception catch (e) {
204- _log.severe ('Failed to initialize application dependencies' , e);
204+ } catch (e, s ) {
205+ _log.severe ('Failed to initialize application dependencies' , e, s );
205206 _initializationError = e;
207+ _initializationStackTrace = s;
206208 rethrow ;
207209 }
208210 }
0 commit comments