From 9010218b107359b60c8b7cd796a60e890a8d5bf1 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 11 Mar 2023 19:06:28 +0100 Subject: [PATCH] refactor(core): Move connection errors into their own file --- packages/moxxmpp/lib/src/connection.dart | 27 +----------------- .../moxxmpp/lib/src/connection_errors.dart | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 packages/moxxmpp/lib/src/connection_errors.dart diff --git a/packages/moxxmpp/lib/src/connection.dart b/packages/moxxmpp/lib/src/connection.dart index eb1f906..bf5483e 100644 --- a/packages/moxxmpp/lib/src/connection.dart +++ b/packages/moxxmpp/lib/src/connection.dart @@ -4,6 +4,7 @@ import 'package:meta/meta.dart'; import 'package:moxlib/moxlib.dart'; import 'package:moxxmpp/src/awaiter.dart'; import 'package:moxxmpp/src/buffer.dart'; +import 'package:moxxmpp/src/connection_errors.dart'; import 'package:moxxmpp/src/connectivity.dart'; import 'package:moxxmpp/src/errors.dart'; import 'package:moxxmpp/src/events.dart'; @@ -91,32 +92,6 @@ class XmppConnectionResult { final XmppError? error; } -/// The reason a call to [XmppConnection.connect] failed. -abstract class XmppConnectionError {} - -/// Returned by [XmppConnection.connect] when a connection is already active. -class ConnectionAlreadyRunningError extends XmppConnectionError {} - -/// Returned by [XmppConnection.connect] when a negotiator returned an unrecoverable -/// error. Only returned when waitUntilLogin is true. -class NegotiatorReturnedError extends XmppConnectionError { - NegotiatorReturnedError(this.error); - - /// The error returned by the negotiator. - final NegotiatorError error; -} - -class StreamFailureError extends XmppConnectionError { - StreamFailureError(this.error); - - /// The error that causes a connection failure. - final XmppError error; -} - -/// Returned by [XmppConnection.connect] when no connection could -/// be established. -class NoConnectionPossibleError extends XmppConnectionError {} - /// This class is a connection to the server. class XmppConnection { XmppConnection( diff --git a/packages/moxxmpp/lib/src/connection_errors.dart b/packages/moxxmpp/lib/src/connection_errors.dart new file mode 100644 index 0000000..304dee2 --- /dev/null +++ b/packages/moxxmpp/lib/src/connection_errors.dart @@ -0,0 +1,28 @@ +import 'package:moxxmpp/src/errors.dart'; +import 'package:moxxmpp/src/negotiators/negotiator.dart'; + +/// The reason a call to `XmppConnection.connect` failed. +abstract class XmppConnectionError {} + +/// Returned by `XmppConnection.connect` when a connection is already active. +class ConnectionAlreadyRunningError extends XmppConnectionError {} + +/// Returned by `XmppConnection.connect` when a negotiator returned an unrecoverable +/// error. Only returned when waitUntilLogin is true. +class NegotiatorReturnedError extends XmppConnectionError { + NegotiatorReturnedError(this.error); + + /// The error returned by the negotiator. + final NegotiatorError error; +} + +class StreamFailureError extends XmppConnectionError { + StreamFailureError(this.error); + + /// The error that causes a connection failure. + final XmppError error; +} + +/// Returned by `XmppConnection.connect` when no connection could +/// be established. +class NoConnectionPossibleError extends XmppConnectionError {}