1#ifndef __FACADE_EXCEPTION_HPP
2#define __FACADE_EXCEPTION_HPP
30 const char *
what() const noexcept {
31 return this->error.c_str();
43 "Chunk tags can only be 4 characters long.") {}
56 std::stringstream stream;
58 stream <<
"Out of bounds: the given index is "
60 <<
", but the boundary is "
63 this->
error = stream.str();
91 std::stringstream stream;
93 stream <<
"Bad CRC: the given CRC was "
94 << std::hex << std::showbase << std::uppercase
96 <<
", but the expected CRC was "
99 this->
error = stream.str();
111 std::stringstream stream;
113 stream <<
"Open file failure: failed to open file with name \""
117 this->
error = stream.str();
131 std::stringstream stream;
133 stream <<
"Insufficient size: given a size of "
135 <<
", but needed at least "
138 this->
error = stream.str();
158 std::stringstream stream;
160 stream <<
"ZLib error: ZLib encountered an error while compressing/decompressiong, error code "
163 this->
error = stream.str();
179 "or the canvas was not initialized.") {}
187 "raw pixel data.") {}
205 std::stringstream stream;
207 stream <<
"Invalid color type: the encountered color type value (" <<
static_cast<int>(
color_type) <<
") is invalid.";
209 this->
error = stream.str();
223 std::stringstream stream;
225 stream <<
"Invalid bit depth: the encountered bit depth (" <<
bit_depth <<
") is invalid. ";
226 stream <<
"Valid values can be 1, 2, 4, 8 and 16.";
228 this->
error = stream.str();
247 std::stringstream stream;
249 stream <<
"Invalid filter type: the given filter type " <<
static_cast<int>(
filter_type) <<
" was not a valid value.";
251 this->
error = stream.str();
273 std::stringstream stream;
275 stream <<
"Integer overflow: the given number was " <<
given
276 <<
", but the maximum value is " << max;
278 this->
error = stream.str();
297 std::stringstream stream;
299 stream <<
"Invalid pixel type: the given pixel type, " <<
pixel_type <<
", is invalid.";
301 this->
error = stream.str();
337 std::stringstream stream;
339 stream <<
"Invalid Base64 character: the given character, '" <<
c <<
"', is not a valid Base64 character.";
341 this->
error = stream.str();
353 std::stringstream stream;
355 stream <<
"Invalid Base64 string: the given string is not a valid Base64 string: " <<
string;
357 this->
error = stream.str();
369 std::stringstream stream;
371 stream <<
"Unsupported pixel type: the given pixel-type value, " <<
pixel_type <<
", is unsupported for the given operation.";
373 this->
error = stream.str();
387 std::stringstream stream;
389 stream <<
"Image too small: the image wasn't large enough to support the operation. The image can hold "
390 <<
given <<
" bytes of data, but needed at least " <<
needed;
392 this->
error = stream.str();
411 std::stringstream stream;
413 stream <<
"Chunk not found: chunks with the tag \"" <<
tag <<
"\" could not be found in the image.";
415 this->
error = stream.str();
427 std::stringstream stream;
429 stream <<
"Invalid bit offset: the given bit offset, " <<
offset <<
", was not divisble by 4.";
431 this->
error = stream.str();
An exception thrown when the PNG image has already been filtered.
Definition: exception.hpp:257
AlreadyFiltered()
Definition: exception.hpp:259
An exception thrown when the CRC didn't match expectations.
Definition: exception.hpp:83
std::uint32_t expected
The expected CRC.
Definition: exception.hpp:88
BadCRC(std::uint32_t given, std::uint32_t expected)
Definition: exception.hpp:90
std::uint32_t given
The bad CRC.
Definition: exception.hpp:86
An exception thrown when the signature header of a given binary stream is not a PNG header.
Definition: exception.hpp:76
BadPNGSignature()
Definition: exception.hpp:78
An exception thrown when the chunk is not found in the PNG data.
Definition: exception.hpp:405
ChunkNotFound(std::string tag)
Definition: exception.hpp:410
std::string tag
The chunk tag which could not be found.
Definition: exception.hpp:408
The base exception that all exceptions in this library are built upon.
Definition: exception.hpp:20
const char * what() const noexcept
Get a C-string representation of the error. Adds compatibility with std::exception.
Definition: exception.hpp:30
Exception()
Definition: exception.hpp:25
Exception(const std::string &error)
Definition: exception.hpp:26
std::string error
The resulting error string provided by the exception.
Definition: exception.hpp:23
An exception thrown when the possible space provided by the image data is too small for the given ope...
Definition: exception.hpp:379
std::size_t needed
The amount of space needed by the operation.
Definition: exception.hpp:384
std::size_t given
The amount of data the given image can hold, in bytes.
Definition: exception.hpp:382
ImageTooSmall(std::size_t given, std::size_t needed)
Definition: exception.hpp:386
An exception thrown when there was not enough data to complete the operation.
Definition: exception.hpp:123
std::size_t given
The offending size.
Definition: exception.hpp:126
InsufficientSize(std::size_t given, std::size_t minimum)
Definition: exception.hpp:130
std::size_t minimum
The minimum size needed to complete the operation.
Definition: exception.hpp:128
An exception thrown when a given integer overflows.
Definition: exception.hpp:264
std::size_t given
The given value which caused the overflow.
Definition: exception.hpp:267
std::size_t max_
The maximum value that can be given.
Definition: exception.hpp:270
IntegerOverflow(std::size_t given, std::size_t max)
Definition: exception.hpp:272
An exception thrown when encountering an invalid Base64 character.
Definition: exception.hpp:331
char c
The offending character which was encountered.
Definition: exception.hpp:334
InvalidBase64Character(char c)
Definition: exception.hpp:336
An exception thrown when encountering an invalid base64 string.
Definition: exception.hpp:347
InvalidBase64String(const std::string &string)
Definition: exception.hpp:352
std::string string
The offending string.
Definition: exception.hpp:350
An exception thrown when the given bit depth isn't a valid value.
Definition: exception.hpp:217
std::uint8_t bit_depth
The offending bit depth value.
Definition: exception.hpp:220
InvalidBitDepth(std::uint8_t bit_depth)
Definition: exception.hpp:222
An exception thrown when the given bit offset is not a multiple of 4.
Definition: exception.hpp:421
InvalidBitOffset(std::size_t offset)
Definition: exception.hpp:426
std::size_t offset
The offending offset.
Definition: exception.hpp:424
An exception thrown when a provided chunk tag is not valid.
Definition: exception.hpp:40
InvalidChunkTag()
Definition: exception.hpp:42
An exception thrown when the color type does not match the facade::png::ColorType enum.
Definition: exception.hpp:199
std::uint8_t color_type
The offending color type value.
Definition: exception.hpp:202
InvalidColorType(std::uint8_t color_type)
Definition: exception.hpp:204
An exception thrown when the given filter type does not match the facade::png::FilterType enum.
Definition: exception.hpp:241
InvalidFilterType(std::uint8_t filter_type)
Definition: exception.hpp:246
std::uint8_t filter_type
The offending filter type value.
Definition: exception.hpp:244
An exception thrown when the pixel type does not match the facade::png::PixelEnum enum.
Definition: exception.hpp:291
std::size_t pixel_type
The offending pixel type value.
Definition: exception.hpp:294
InvalidPixelType(std::size_t pixel_type)
Definition: exception.hpp:296
An exception thrown when the given keyword is too long for the tEXt or zTXt chunk.
Definition: exception.hpp:316
KeywordTooLong()
Definition: exception.hpp:318
An exception thrown when no data is provided.
Definition: exception.hpp:284
NoData()
Definition: exception.hpp:286
An exception thrown when encountering no image data within an icon object.
Definition: exception.hpp:451
NoIconData()
Definition: exception.hpp:453
An exception thrown when no image data chunks are present in the PNG file.
Definition: exception.hpp:169
NoImageDataChunks()
Definition: exception.hpp:171
An exception thrown when image data is not currently loaded in the PNG object.
Definition: exception.hpp:176
NoImageData()
Definition: exception.hpp:178
An exception thrown when no keyword is present in the given tEXt or zTXt chunk of a PNG image.
Definition: exception.hpp:307
NoKeyword()
Definition: exception.hpp:309
An exception thrown when no PNG image is present in icon data.
Definition: exception.hpp:458
NoPNGIcon()
Definition: exception.hpp:460
An exception thrown when no pixels appear in a given scanline.
Definition: exception.hpp:192
NoPixels()
Definition: exception.hpp:194
An exception thrown when no steganographic data is present.
Definition: exception.hpp:398
NoStegoData()
Definition: exception.hpp:400
An exception thrown when no trailing data is present in the PNG image.
Definition: exception.hpp:437
NoTrailingData()
Definition: exception.hpp:439
An exception thrown when encountering a null pointer.
Definition: exception.hpp:69
NullPointer()
Definition: exception.hpp:71
An exception thrown when a file couldn't be opened, either for reading or writing.
Definition: exception.hpp:105
std::string filename
The file which could not be opened.
Definition: exception.hpp:108
OpenFileFailure(const std::string &filename)
Definition: exception.hpp:110
An exception thrown when the operation goes out of bounds.
Definition: exception.hpp:48
std::size_t boundary
The boundary the offense broke.
Definition: exception.hpp:53
std::size_t given
The offending boundary.
Definition: exception.hpp:51
OutOfBounds(std::size_t given, std::size_t boundary)
Definition: exception.hpp:55
An exception thrown when pixel types do not match up.
Definition: exception.hpp:184
PixelMismatch()
Definition: exception.hpp:186
An exception thrown when the scanline pixel types do not match up.
Definition: exception.hpp:234
ScanlineMismatch()
Definition: exception.hpp:236
An exception returned when the given tEXt or zTXt section parameters (typically the keyword) is not f...
Definition: exception.hpp:323
TextNotFound()
Definition: exception.hpp:325
An exception thrown when the given pixel enum type is not supported.
Definition: exception.hpp:363
UnsupportedPixelType(std::size_t pixel_type)
Definition: exception.hpp:368
std::size_t pixel_type
The offending pixel type.
Definition: exception.hpp:366
An exception thrown when encountering a ZLib error.
Definition: exception.hpp:151
int code
The code returned by zlib.
Definition: exception.hpp:155
ZLibError(int code)
Definition: exception.hpp:157
Definition: exception.hpp:14