src/XMLDocumentConstructor.h
branchv_0
changeset 10 6904e4448807
parent 7 afb7f3a4981a
child 13 d5e2cb9e31f1
--- a/src/XMLDocumentConstructor.h	Sat Jun 12 22:37:44 2021 +0200
+++ b/src/XMLDocumentConstructor.h	Sat Jun 19 12:59:07 2021 +0200
@@ -23,6 +23,7 @@
 #include "lib/BasicASN1Reader.h"
 #include "lib/GenericASN1ContentHandler.h"
 #include "lib/DOMBuildingXMLContentHandler.h"
+#include "lib/TransactionalBuffer.h"
 
 namespace relpipe {
 namespace in {
@@ -50,10 +51,17 @@
 		reader.addHandler(asn1handler);
 
 
-		// TODO: buffering? (reader itself also buffers)
-		for (char ch = input->get(); input->good(); ch = input->get()) reader.write(&ch, 1);
+		try {
+			// TODO: buffering? (reader itself also buffers)
+			for (char ch = input->get(); input->good(); ch = input->get()) reader.write(&ch, 1);
+		} catch (const relpipe::in::asn1::lib::TransactionalBuffer::WriteBufferOverflowException& e) {
+			// TODO: avoid leaky abstraction and use different exception
+			throw relpipe::writer::RelpipeWriterException(L"Transactional buffer for ASN.1 input is too small");
+		}
 
 		reader.close();
+
+		if (parser->get_document()->get_root_node() == nullptr) throw relpipe::writer::RelpipeWriterException(L"Empty ASN.1 input"); // TODO: move to common class
 	}
 };