diff --git a/lib/src/core/signal_client.dart b/lib/src/core/signal_client.dart index af33830..cdef44a 100644 --- a/lib/src/core/signal_client.dart +++ b/lib/src/core/signal_client.dart @@ -90,6 +90,7 @@ class SignalClient extends Disposable with EventsEmittable { _updateConnectionState(ConnectionState.connected); } catch (socketError) { // Attempt Validation + var finalError = socketError; try { // Skip validation if reconnect mode if (reconnect) rethrow; @@ -106,17 +107,15 @@ class SignalClient extends Disposable with EventsEmittable { final validateResponse = await http.get(validateUri); if (validateResponse.statusCode != 200) { - throw ConnectException(validateResponse.body); + finalError = ConnectException(validateResponse.body); } - throw ConnectException(); } catch (error) { - // Pass it up if it's already a `ConnectError` - if (error is ConnectException) rethrow; - // HTTP doesn't work either - throw ConnectException(); + if (socketError.runtimeType != error.runtimeType) { + finalError = error; + } } finally { _updateConnectionState(ConnectionState.disconnected); - rethrow; + throw finalError; } } } diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index 638a718..41eee83 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -4,7 +4,7 @@ abstract class LiveKitException implements Exception { const LiveKitException._(this.message); @override - String toString() => 'LiveKit Exception $runtimeType $message'; + String toString() => 'LiveKit Exception: [$runtimeType] $message'; } /// An exception occured while attempting to connect.