mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
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:
parent
d9718064d1
commit
96fb4b20f1
|
@ -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>;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue