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.
This commit is contained in:
Rodrigo Tobar 2022-12-14 22:57:39 +08:00 committed by Andreas Kling
parent d9718064d1
commit 96fb4b20f1

View file

@ -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>;
}