-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_exceptions.h
47 lines (40 loc) · 1.07 KB
/
my_exceptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Created by Тимофей Жамойдин on 23.10.22.
//
#pragma once
#include "exception"
#include "string"
#include "sstream"
class FilePathException : public std::exception {
private:
std::string error_message_;
public:
explicit FilePathException(std::string& filename) {
error_message_ = "File " + filename + " not found";
}
const char* what() const throw() override {
return error_message_.c_str();
}
};
class BadArgumentException : public std::exception {
private:
std::string error_message_;
public:
explicit BadArgumentException(const std::string& message) {
error_message_ = message;
}
const char* what() const throw() override {
return error_message_.c_str();
}
};
class DamagedDataException : public std::exception {
private:
std::string error_message_;
public:
explicit DamagedDataException(std::string& archive_name) {
error_message_ = "Data in " + archive_name + "was damaged";
}
const char* what() const throw() override {
return error_message_.c_str();
}
};