fix: Correctly throws final error when connection fails. (#214)
* fix: Correctly throws final error when connection fails. * update. * update.
This commit is contained in:
@@ -90,6 +90,7 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
|
|||||||
_updateConnectionState(ConnectionState.connected);
|
_updateConnectionState(ConnectionState.connected);
|
||||||
} catch (socketError) {
|
} catch (socketError) {
|
||||||
// Attempt Validation
|
// Attempt Validation
|
||||||
|
var finalError = socketError;
|
||||||
try {
|
try {
|
||||||
// Skip validation if reconnect mode
|
// Skip validation if reconnect mode
|
||||||
if (reconnect) rethrow;
|
if (reconnect) rethrow;
|
||||||
@@ -106,17 +107,15 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
|
|||||||
|
|
||||||
final validateResponse = await http.get(validateUri);
|
final validateResponse = await http.get(validateUri);
|
||||||
if (validateResponse.statusCode != 200) {
|
if (validateResponse.statusCode != 200) {
|
||||||
throw ConnectException(validateResponse.body);
|
finalError = ConnectException(validateResponse.body);
|
||||||
}
|
}
|
||||||
throw ConnectException();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Pass it up if it's already a `ConnectError`
|
if (socketError.runtimeType != error.runtimeType) {
|
||||||
if (error is ConnectException) rethrow;
|
finalError = error;
|
||||||
// HTTP doesn't work either
|
}
|
||||||
throw ConnectException();
|
|
||||||
} finally {
|
} finally {
|
||||||
_updateConnectionState(ConnectionState.disconnected);
|
_updateConnectionState(ConnectionState.disconnected);
|
||||||
rethrow;
|
throw finalError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ abstract class LiveKitException implements Exception {
|
|||||||
const LiveKitException._(this.message);
|
const LiveKitException._(this.message);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'LiveKit Exception $runtimeType $message';
|
String toString() => 'LiveKit Exception: [$runtimeType] $message';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An exception occured while attempting to connect.
|
/// An exception occured while attempting to connect.
|
||||||
|
|||||||
Reference in New Issue
Block a user