Skip to content

Commit 7ef8894

Browse files
committed
Print an error if an unsupported image format is created
1 parent 18c9c32 commit 7ef8894

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/scratchconfiguration.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <scratchcpp/scratchconfiguration.h>
44
#include <scratchcpp/iimageformatfactory.h>
5+
#include <iostream>
56

67
#include "scratchconfiguration_p.h"
78
#include "blocks/standardblocks.h"
@@ -40,9 +41,12 @@ std::shared_ptr<IImageFormat> ScratchConfiguration::createImageFormat(const std:
4041
{
4142
auto it = impl->imageFormats.find(name);
4243

43-
if (it == impl->imageFormats.cend())
44-
return std::make_shared<ImageFormatStub>(); // use stub if the format doesn't exist
45-
else
44+
if (it == impl->imageFormats.cend()) {
45+
std::cerr << "Unsupported image format: " << name << std::endl;
46+
47+
// Use stub if the format doesn't exist
48+
return std::make_shared<ImageFormatStub>();
49+
} else
4650
return it->second->createInstance();
4751
}
4852

0 commit comments

Comments
 (0)