diff --git a/exception.h b/exception.h new file mode 100644 index 0000000000000000000000000000000000000000..efa567221c761a78b594b1240d4e7c849b959c7d --- /dev/null +++ b/exception.h @@ -0,0 +1,37 @@ +#ifndef LABORATORY_WORK_1_2_EXCEPTIONS_H +#define LABORATORY_WORK_1_2_EXCEPTIONS_H + + +#include +#include + + +class BadFileFormatException : public std::exception { + std::string error; +public: + BadFileFormatException() { + error.assign("Unknown or unsupported file format!"); + } + explicit BadFileFormatException(const std::string& file_format) { + error.assign("File format \"" + file_format + "\" is not supported!"); + } + const char* what() const noexcept override { + return error.c_str(); + } +}; + +class NoFileFoundException : public std::exception { + std::string error; +public: + NoFileFoundException() { + error.assign("Cannot open file! Probably it does not exist!"); + } + explicit NoFileFoundException(const std::string& file_) { + error.assign("Cannot open file: \"" + file_ + "\"! Probably it does not exist!"); + } + const char* what() const noexcept override { + return error.c_str(); + } +}; + +#endif