diff options
author | Rodrigo Tobar <rtobar@icrar.org> | 2022-12-14 22:57:39 +0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-16 10:04:23 +0100 |
commit | 96fb4b20f19a1487cc22cf3b7f7db0a33f65ebc2 (patch) | |
tree | ee7b1dd982c17a6cab34d0a10e1c94befe50f932 /Userland/Libraries/LibPDF/Error.h | |
parent | d9718064d1ac1f165fd6d69eb552a4918f3d1198 (diff) | |
download | serenity-96fb4b20f19a1487cc22cf3b7f7db0a33f65ebc2.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibPDF/Error.h')
-rw-r--r-- | Userland/Libraries/LibPDF/Error.h | 27 |
1 files changed, 27 insertions, 0 deletions
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 <AK/DeprecatedString.h> +#include <AK/Vector.h> namespace PDF { @@ -52,7 +53,33 @@ private: DeprecatedString m_message; }; +class Errors { + +public: + Errors() = default; + Errors(Error&& error) + { + m_errors.empend(move(error)); + } + + Vector<Error> const& errors() const + { + return m_errors; + } + + void add_error(Error&& error) + { + m_errors.empend(move(error)); + } + +private: + Vector<Error> m_errors; +}; + template<typename T> using PDFErrorOr = ErrorOr<T, Error>; +template<typename T> +using PDFErrorsOr = ErrorOr<T, Errors>; + } |