From 5a79c69b0216f070b07d8238e4c2c7e3420faeec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Nov 2021 14:29:33 +0100 Subject: LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<> This is a first step towards better error propagation from image codecs. --- Userland/Libraries/LibGfx/PGMLoader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Userland/Libraries/LibGfx/PGMLoader.cpp') diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp index 837563e27b..9280f7f528 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.cpp +++ b/Userland/Libraries/LibGfx/PGMLoader.cpp @@ -165,22 +165,22 @@ size_t PGMImageDecoderPlugin::frame_count() return 1; } -ImageFrameDescriptor PGMImageDecoderPlugin::frame(size_t i) +ErrorOr PGMImageDecoderPlugin::frame(size_t index) { - if (i > 0) - return {}; + if (index > 0) + return Error::from_string_literal("PGMImageDecoderPlugin: Invalid frame index"sv); if (m_context->state == PGMLoadingContext::State::Error) - return {}; + return Error::from_string_literal("PGMImageDecoderPlugin: Decoding failed"sv); if (m_context->state < PGMLoadingContext::State::Decoded) { bool success = decode(*m_context); if (!success) - return {}; + return Error::from_string_literal("PGMImageDecoderPlugin: Decoding failed"sv); } VERIFY(m_context->bitmap); - return { m_context->bitmap, 0 }; + return ImageFrameDescriptor { m_context->bitmap, 0 }; } } -- cgit v1.2.3