From dbd60f9ff4071286f5e59d24f6269147322512ae Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 26 Nov 2021 22:33:04 +0100 Subject: [PATCH] AK: Implement Formatter for ErrorOr<> As the Formatter for Error already exists, this apparently was just accidentally omitted. --- AK/Format.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AK/Format.h b/AK/Format.h index 90f2b5bf18..36221884d9 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -624,6 +624,16 @@ struct Formatter : Formatter { } }; +template +struct Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, ErrorOr const& error_or) + { + if (error_or.is_error()) + return Formatter::format(builder, "{}", error_or.error()); + return Formatter::format(builder, "{{{}}}", error_or.value()); + } +}; + } // namespace AK #ifdef KERNEL