-
Notifications
You must be signed in to change notification settings - Fork 0
/
huffman_exceptions.hpp
78 lines (58 loc) · 1.8 KB
/
huffman_exceptions.hpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* ****************************************************************************
* File: Huffman compressor exceptions.
* Author: Devid Dokash.
* Date: 03/03/2022.
* ***************************************************************************/
#pragma once
#include <exception>
#include <string>
struct file_not_found : public std::exception {
std::string file;
std::string msg;
file_not_found(std::string file) : file(file) {
msg = ("huf: error: file \'" + file + "\' was not found.");
}
const char * what () const throw () {
return msg.c_str();
}
};
struct empty_file : public std::exception {
std::string file;
std::string msg;
empty_file(std::string file) : file(file) {
msg = "\nhuf: warning -- file \'" + file + "\' was empty, no compression done...";
}
const char * what () const throw () {
return msg.c_str();
}
};
struct no_huffman_file : public std::exception {
std::string file;
std::string msg;
no_huffman_file(std::string file) : file(file) {
msg = "\nhuf: error -- \'" + file + "\' is not a huffman file...";
}
const char * what () const throw () {
return msg.c_str();
}
};
struct unknown_option : public std::exception {
std::string option;
std::string msg;
unknown_option(std::string option) : option(option) {
msg = "\nhuf: error: unknown option \'" + option + "\'.";
}
const char * what () const throw () {
return msg.c_str();
}
};
struct bad_arguments_number : public std::exception {
std::string option;
std::string msg;
bad_arguments_number(std::string option) : option(option) {
msg = ("version: error: option \'" + option + "\' requires a file to work");
}
const char * what () const throw () {
return msg.c_str();
}
};