From fea0dbba17247ac238813c9ec5a3495f8be0f469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=9E=D1=80=D0=B5=D1=85?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sat, 21 Nov 2020 17:54:24 +0000 Subject: [PATCH] Add new file --- exception.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 exception.h diff --git a/exception.h b/exception.h new file mode 100644 index 0000000..efa5672 --- /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 -- GitLab