From 18321ed15ce782ff5d1f24de9f2fb459d714d125 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 31 Jan 2023 15:12:39 +0100 Subject: Collapse most stream releated errors into IOError --- xmpp-vala/src/module/message/module.vala | 8 ++------ xmpp-vala/src/module/xep/0198_stream_management.vala | 8 ++++---- xmpp-vala/src/module/xep/0444_reactions.vala | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'xmpp-vala/src/module') diff --git a/xmpp-vala/src/module/message/module.vala b/xmpp-vala/src/module/message/module.vala index ef39a663..bb63bca4 100644 --- a/xmpp-vala/src/module/message/module.vala +++ b/xmpp-vala/src/module/message/module.vala @@ -15,13 +15,9 @@ namespace Xmpp { public signal void received_error(XmppStream stream, MessageStanza message, ErrorStanza error); public signal void received_message_unprocessed(XmppStream stream, MessageStanza message); - public async void send_message(XmppStream stream, MessageStanza message) throws IOStreamError { + public async void send_message(XmppStream stream, MessageStanza message) throws IOError { yield send_pipeline.run(stream, message); - try { - yield stream.write_async(message.stanza); - } catch (IOStreamError e) { - throw new SendError.IO(e.message); - } + yield stream.write_async(message.stanza); } public async void received_message_stanza_async(XmppStream stream, StanzaNode node) { diff --git a/xmpp-vala/src/module/xep/0198_stream_management.vala b/xmpp-vala/src/module/xep/0198_stream_management.vala index 5ce208f1..340c4e6f 100644 --- a/xmpp-vala/src/module/xep/0198_stream_management.vala +++ b/xmpp-vala/src/module/xep/0198_stream_management.vala @@ -25,7 +25,7 @@ public class Module : XmppStreamNegotiationModule, WriteNodeFunc { } } - public async void write_stanza(XmppStream stream, StanzaNode node) throws IOStreamError { + public async void write_stanza(XmppStream stream, StanzaNode node) throws IOError { var promise = new Promise(); node_queue.add(new QueueItem(node, promise)); @@ -34,7 +34,7 @@ public class Module : XmppStreamNegotiationModule, WriteNodeFunc { try { yield promise.future.wait_async(); } catch (FutureError e) { - throw new IOStreamError.WRITE("Future returned error %i".printf(e.code)); + throw new IOError.FAILED("Future returned error %i".printf(e.code)); } } @@ -50,7 +50,7 @@ public class Module : XmppStreamNegotiationModule, WriteNodeFunc { } else { yield ((!)writer).write_node(node); } - } catch (XmlError e) { } + } catch (IOError e) { } } private void check_queue(XmppStream stream) { @@ -158,7 +158,7 @@ public class Module : XmppStreamNegotiationModule, WriteNodeFunc { handle_incoming_h(stream, h_outbound); } foreach (var id in in_flight_stanzas.keys) { - in_flight_stanzas[id].promise.set_exception(new IOStreamError.WRITE("Stanza not acked and session not resumed")); + in_flight_stanzas[id].promise.set_exception(new IOError.FAILED("Stanza not acked and session not resumed")); } in_flight_stanzas.clear(); check_queue(stream); diff --git a/xmpp-vala/src/module/xep/0444_reactions.vala b/xmpp-vala/src/module/xep/0444_reactions.vala index 6e76f1f0..877d3070 100644 --- a/xmpp-vala/src/module/xep/0444_reactions.vala +++ b/xmpp-vala/src/module/xep/0444_reactions.vala @@ -11,7 +11,7 @@ public class Module : XmppStreamModule { private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener(); - public async void send_reaction(XmppStream stream, Jid jid, string stanza_type, string message_id, Gee.List reactions) throws SendError { + public async void send_reaction(XmppStream stream, Jid jid, string stanza_type, string message_id, Gee.List reactions) throws IOError { StanzaNode reactions_node = new StanzaNode.build("reactions", NS_URI).add_self_xmlns(); reactions_node.put_attribute("id", message_id); foreach (string reaction in reactions) { -- cgit v1.2.3-70-g09d2