-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
63 lines (58 loc) · 1.63 KB
/
error.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <stdexcept>
enum struct ErrorType {
StdIoError,
UnexpectedEof,
SizeTooLarge,
EmptyInput,
InvalidGzHeader,
InvalidBlockType,
BlockType0LenMismatch,
InvalidCodeLengths,
HuffmanDecoderCodeNotFound,
DistanceTooMuch,
EndOfBlockNotFound,
ReadDynamicCodebook,
ChecksumMismatch,
SizeMismatch,
};
struct Error : public std::exception {
public:
explicit Error(ErrorType error_type) : error_type{error_type} {}
const char* what() const noexcept override {
switch (error_type) {
case ErrorType::StdIoError:
return "StdIoError";
case ErrorType::UnexpectedEof:
return "UnexpectedEof";
case ErrorType::SizeTooLarge:
return "SizeTooLarge";
case ErrorType::EmptyInput:
return "EmptyInput";
case ErrorType::InvalidGzHeader:
return "InvalidGzHeader";
case ErrorType::InvalidBlockType:
return "InvalidBlockType";
case ErrorType::BlockType0LenMismatch:
return "BlockType0LenMismatch";
case ErrorType::InvalidCodeLengths:
return "InvalidCodeLengths";
case ErrorType::HuffmanDecoderCodeNotFound:
return "HuffmanDecoderCodeNotFound";
case ErrorType::DistanceTooMuch:
return "DistanceTooMuch";
case ErrorType::EndOfBlockNotFound:
return "EndOfBlockNotFound";
case ErrorType::ReadDynamicCodebook:
return "ReadDynamicCodebook";
case ErrorType::ChecksumMismatch:
return "ChecksumMismatch";
case ErrorType::SizeMismatch:
return "SizeMismatch";
default:
return "Unknown Error";
}
}
private:
ErrorType error_type;
};