mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
image: Don't just crash when the input file can't be decoded
If the input file didn't exist at all, the TRY(MappedFile::map()) gives us a (cryptic) error message, but if it existed but wasn't an image file, we would crash. Now we print a message instead.
This commit is contained in:
parent
0591aa1d96
commit
3a7257c9fe
1 changed files with 4 additions and 0 deletions
|
@ -41,6 +41,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto file = TRY(Core::MappedFile::map(in_path));
|
||||
auto decoder = Gfx::ImageDecoder::try_create_for_raw_bytes(file->bytes());
|
||||
if (!decoder) {
|
||||
warnln("Failed to decode input file '{}'", in_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This uses ImageDecoder instead of Bitmap::load_from_file() to have more control
|
||||
// over selecting a frame, access color profile data, and so on in the future.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue