fix(core): Fix crash when no negotiator matches
Fixes #30. Also removes the `allowPlainAuth` attribute of `ConnectionSettings` as users who want to disable SASL PLAIN can just not register the negotiator or extend it.
This commit is contained in:
@@ -2,16 +2,22 @@ import 'package:moxxmpp/src/errors.dart';
|
||||
import 'package:moxxmpp/src/negotiators/negotiator.dart';
|
||||
|
||||
/// The reason a call to `XmppConnection.connect` failed.
|
||||
abstract class XmppConnectionError {}
|
||||
abstract class XmppConnectionError extends XmppError {}
|
||||
|
||||
/// Returned by `XmppConnection.connect` when a connection is already active.
|
||||
class ConnectionAlreadyRunningError extends XmppConnectionError {}
|
||||
class ConnectionAlreadyRunningError extends XmppConnectionError {
|
||||
@override
|
||||
bool isRecoverable() => true;
|
||||
}
|
||||
|
||||
/// Returned by `XmppConnection.connect` when a negotiator returned an unrecoverable
|
||||
/// error. Only returned when waitUntilLogin is true.
|
||||
class NegotiatorReturnedError extends XmppConnectionError {
|
||||
NegotiatorReturnedError(this.error);
|
||||
|
||||
@override
|
||||
bool isRecoverable() => error.isRecoverable();
|
||||
|
||||
/// The error returned by the negotiator.
|
||||
final NegotiatorError error;
|
||||
}
|
||||
@@ -19,10 +25,30 @@ class NegotiatorReturnedError extends XmppConnectionError {
|
||||
class StreamFailureError extends XmppConnectionError {
|
||||
StreamFailureError(this.error);
|
||||
|
||||
@override
|
||||
bool isRecoverable() => error.isRecoverable();
|
||||
|
||||
/// The error that causes a connection failure.
|
||||
final XmppError error;
|
||||
}
|
||||
|
||||
/// Returned by `XmppConnection.connect` when no connection could
|
||||
/// be established.
|
||||
class NoConnectionPossibleError extends XmppConnectionError {}
|
||||
class NoConnectionPossibleError extends XmppConnectionError {
|
||||
@override
|
||||
bool isRecoverable() => true;
|
||||
}
|
||||
|
||||
/// Returned if no matching authentication mechanism has been presented
|
||||
class NoMatchingAuthenticationMechanismAvailableError
|
||||
extends XmppConnectionError {
|
||||
@override
|
||||
bool isRecoverable() => false;
|
||||
}
|
||||
|
||||
/// Returned if no negotiator was picked, even though negotiations are not done
|
||||
/// yet.
|
||||
class NoAuthenticatorAvailableError extends XmppConnectionError {
|
||||
@override
|
||||
bool isRecoverable() => false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user