Skip to content

Commit 0ebf7f5

Browse files
committed
refactored string No clients available for ....
1 parent 7c1a074 commit 0ebf7f5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

dwds/lib/src/services/web_socket_proxy_service.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ const _pauseIsolatesOnStartFlag = 'pause_isolates_on_start';
3333
/// closes before the new connection is established, preventing premature isolate destruction.
3434
const _isolateDestructionGracePeriod = Duration(seconds: 15);
3535

36+
/// Error message when no clients are available for hot reload.
37+
const _noClientsForHotReload = 'No clients available for hot reload';
38+
39+
/// Error message when no clients are available for hot restart.
40+
const _noClientsForHotRestart = 'No clients available for hot restart';
41+
3642
/// Tracks hot reload responses from multiple browser windows/tabs.
3743
class _HotReloadTracker {
3844
final String requestId;
@@ -121,7 +127,13 @@ class _ServiceExtensionTracker {
121127
class NoClientsAvailableException implements Exception {
122128
final String message;
123129

124-
NoClientsAvailableException(this.message);
130+
NoClientsAvailableException._(this.message);
131+
132+
factory NoClientsAvailableException.hotReload() =>
133+
NoClientsAvailableException._(_noClientsForHotReload);
134+
135+
factory NoClientsAvailableException.hotRestart() =>
136+
NoClientsAvailableException._(_noClientsForHotRestart);
125137

126138
@override
127139
String toString() => 'NoClientsAvailableException: $message';
@@ -637,8 +649,8 @@ class WebSocketProxyService extends ProxyService {
637649
});
638650

639651
if (clientCount == 0) {
640-
_logger.warning('No clients available for hot reload');
641-
throw NoClientsAvailableException('No clients available for hot reload');
652+
_logger.warning(_noClientsForHotReload);
653+
throw NoClientsAvailableException.hotReload();
642654
}
643655

644656
// Create tracker for this hot reload request
@@ -698,8 +710,8 @@ class WebSocketProxyService extends ProxyService {
698710
});
699711

700712
if (clientCount == 0) {
701-
_logger.warning('No clients available for hot restart');
702-
throw NoClientsAvailableException('No clients available for hot restart');
713+
_logger.warning(_noClientsForHotRestart);
714+
throw NoClientsAvailableException.hotRestart();
703715
}
704716

705717
// Create tracker for this hot restart request

0 commit comments

Comments
 (0)