From 96fb4b20f19a1487cc22cf3b7f7db0a33f65ebc2 Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Wed, 14 Dec 2022 22:57:39 +0800 Subject: [PATCH] LibPDF: Add Errors class that accumulate multiple errors This will be used to perform a best-effort rendering, where an error in rendering won't abort the whole rendering operation, but instead will be stored for later reference while rendering continues. --- Userland/Libraries/LibPDF/Error.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Userland/Libraries/LibPDF/Error.h b/Userland/Libraries/LibPDF/Error.h index a2e63a7582..adcf7f51ef 100644 --- a/Userland/Libraries/LibPDF/Error.h +++ b/Userland/Libraries/LibPDF/Error.h @@ -7,6 +7,7 @@ #pragma once #include +#include namespace PDF { @@ -52,7 +53,33 @@ private: DeprecatedString m_message; }; +class Errors { + +public: + Errors() = default; + Errors(Error&& error) + { + m_errors.empend(move(error)); + } + + Vector const& errors() const + { + return m_errors; + } + + void add_error(Error&& error) + { + m_errors.empend(move(error)); + } + +private: + Vector m_errors; +}; + template using PDFErrorOr = ErrorOr; +template +using PDFErrorsOr = ErrorOr; + }