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/core/stanza_writer.vala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'xmpp-vala/src/core/stanza_writer.vala') diff --git a/xmpp-vala/src/core/stanza_writer.vala b/xmpp-vala/src/core/stanza_writer.vala index 62fe022a..5b926a93 100644 --- a/xmpp-vala/src/core/stanza_writer.vala +++ b/xmpp-vala/src/core/stanza_writer.vala @@ -12,11 +12,11 @@ public class StanzaWriter { this.output = output; } - public async void write_node(StanzaNode node) throws XmlError { + public async void write_node(StanzaNode node) throws IOError { yield write_data(node.to_xml().data); } - public async void write_nodes(StanzaNode node1, StanzaNode node2) throws XmlError { + public async void write_nodes(StanzaNode node1, StanzaNode node2) throws IOError { var data1 = node1.to_xml().data; var data2 = node2.to_xml().data; @@ -32,11 +32,11 @@ public class StanzaWriter { yield write_data(concat); } - public async void write(string s) throws XmlError { + public async void write(string s) throws IOError { yield write_data(s.data); } - private async void write_data(owned uint8[] data) throws XmlError { + private async void write_data(owned uint8[] data) throws IOError { if (running) { queue.push_tail(new SourceFuncWrapper(write_data.callback)); yield; @@ -44,9 +44,12 @@ public class StanzaWriter { running = true; try { yield output.write_all_async(data, 0, null, null); + } catch (IOError e) { + cancel(); + throw e; } catch (GLib.Error e) { cancel(); - throw new XmlError.IO(@"IOError in GLib: $(e.message)"); + throw new IOError.FAILED("Error in GLib: %s".printf(e.message)); } finally { SourceFuncWrapper? sfw = queue.pop_head(); if (sfw != null) { -- cgit v1.2.3-54-g00ecf