|
1
|
1 |
|
module Resume |
|
2
|
1 |
|
module CLI |
|
3
|
|
|
# The Base error class that all resume generation-related errors |
|
4
|
|
|
# inherit from. |
|
5
|
|
|
# |
|
6
|
|
|
# @author Paul Fioravanti |
|
7
|
1 |
|
class Error < StandardError |
|
8
|
|
|
# The messages for the error. |
|
9
|
|
|
# |
|
10
|
|
|
# @!attribute messages [r] |
|
11
|
|
|
# @return [Hash] The hash of error messages and their types. |
|
12
|
1 |
|
attr_reader :messages |
|
13
|
|
|
end |
|
14
|
|
|
|
|
15
|
|
|
# Error class for when the very basic prerequisites for running the |
|
16
|
|
|
# resume application are not met. |
|
17
|
|
|
# |
|
18
|
|
|
# @author Paul Fioravanti |
|
19
|
1 |
|
class DependencyPrerequisiteError < Error |
|
20
|
|
|
# Initialises a new instance of the error. |
|
21
|
|
|
# |
|
22
|
|
|
# @return [DependencyPrerequisiteError] The new error instance. |
|
23
|
1 |
|
def initialize |
|
24
|
|
|
@messages = { |
|
25
|
2 |
|
raw_error: |
|
26
|
|
|
"My resume and the specs are bilingual and need the I18n gem.", |
|
27
|
|
|
raw_warning: "Please run: gem install i18n" |
|
28
|
|
|
} |
|
29
|
|
|
end |
|
30
|
|
|
end |
|
31
|
|
|
|
|
32
|
|
|
# Error class for when a connection cannot be made to the internet |
|
33
|
|
|
# to fetch resources needed for resume generation. |
|
34
|
|
|
# |
|
35
|
|
|
# @author Paul Fioravanti |
|
36
|
1 |
|
class NetworkConnectionError < Error |
|
37
|
|
|
# Initialises a new instance of the error. |
|
38
|
|
|
# |
|
39
|
|
|
# @return [NetworkConnectionError] The new error instance. |
|
40
|
1 |
|
def initialize |
|
41
|
|
|
@messages = { |
|
42
|
7 |
|
error: :cant_connect_to_the_internet, |
|
43
|
|
|
warning: :please_check_your_network_settings |
|
44
|
|
|
} |
|
45
|
|
|
end |
|
46
|
|
|
end |
|
47
|
|
|
|
|
48
|
|
|
# Error class for when a permission is not given to download |
|
49
|
|
|
# assets needed for resume generation. |
|
50
|
|
|
# |
|
51
|
|
|
# @author Paul Fioravanti |
|
52
|
1 |
|
class DependencyInstallationPermissionError < Error |
|
53
|
|
|
# Initialises a new instance of the error. |
|
54
|
|
|
# |
|
55
|
|
|
# @return [DependencyInstallationPermissionError] The new error instance. |
|
56
|
1 |
|
def initialize |
|
57
|
|
|
@messages = { |
|
58
|
3 |
|
error: :cannot_generate_pdf_without_dependencies, |
|
59
|
|
|
warning: :please_ask_me_directly_for_a_pdf_copy |
|
60
|
|
|
} |
|
61
|
|
|
end |
|
62
|
|
|
end |
|
63
|
|
|
|
|
64
|
|
|
# Error class for when a installation of a required dependency |
|
65
|
|
|
# fails for whatever reason. |
|
66
|
|
|
# |
|
67
|
|
|
# @author Paul Fioravanti |
|
68
|
1 |
|
class DependencyInstallationError < Error |
|
69
|
|
|
# Initialises a new instance of the error. |
|
70
|
|
|
# |
|
71
|
|
|
# @return [DependencyInstallationError] The new error instance. |
|
72
|
1 |
|
def initialize |
|
73
|
|
|
@messages = { |
|
74
|
3 |
|
error: :dependency_installation_failed, |
|
75
|
|
|
warning: :try_again_or_ask_me_directly_for_a_pdf_copy |
|
76
|
|
|
} |
|
77
|
|
|
end |
|
78
|
|
|
end |
|
79
|
|
|
|
|
80
|
|
|
# Error class for when an invalid or unknown locale is specified |
|
81
|
|
|
# for resume generation. |
|
82
|
|
|
# |
|
83
|
|
|
# @author Paul Fioravanti |
|
84
|
1 |
|
class LocaleNotSupportedError < Error |
|
85
|
|
|
# Initialises a new instance of the error. |
|
86
|
|
|
# |
|
87
|
|
|
# @param locale [String] The unsupported locale |
|
88
|
|
|
# @return [LocaleNotSupportedError] The new error instance. |
|
89
|
1 |
|
def initialize(locale) |
|
90
|
2 |
|
super(locale) |
|
91
|
|
|
@messages = { |
|
92
|
2 |
|
raw_error: "Locale '#{locale}' is not supported", |
|
93
|
|
|
raw_warning: "Supported locales are: "\ |
|
94
|
|
|
"#{I18n.available_locales.join(', ')}" |
|
95
|
|
|
} |
|
96
|
|
|
end |
|
97
|
|
|
end |
|
98
|
|
|
|
|
99
|
|
|
# Error class for when an invalid option is given as a CLI parameter. |
|
100
|
|
|
# |
|
101
|
|
|
# @author Paul Fioravanti |
|
102
|
1 |
|
class InvalidOptionError < Error |
|
103
|
|
|
# Initialises a new instance of the error. |
|
104
|
|
|
# |
|
105
|
|
|
# @param error [String] The error message. |
|
106
|
|
|
# @return [InvalidOptionError] The new error instance. |
|
107
|
1 |
|
def initialize(error) |
|
108
|
2 |
|
super(error) |
|
109
|
|
|
@messages = { |
|
110
|
2 |
|
raw_error: "You have some invalid options.", |
|
111
|
|
|
raw: message |
|
112
|
|
|
} |
|
113
|
|
|
end |
|
114
|
|
|
end |
|
115
|
|
|
|
|
116
|
|
|
# Error class for when a required argument for a CLI option is missing. |
|
117
|
|
|
# |
|
118
|
|
|
# @author Paul Fioravanti |
|
119
|
1 |
|
class MissingArgumentError < Error |
|
120
|
|
|
# Initialises a new instance of the error. |
|
121
|
|
|
# |
|
122
|
|
|
# @param error [String] The error message. |
|
123
|
|
|
# @return [MissingArgumentError] The new error instance. |
|
124
|
1 |
|
def initialize(error) |
|
125
|
2 |
|
super(error) |
|
126
|
|
|
@messages = { |
|
127
|
2 |
|
raw_error: "You have a missing argument in "\ |
|
128
|
|
|
"one of your options.", |
|
129
|
|
|
raw: message |
|
130
|
|
|
} |
|
131
|
|
|
end |
|
132
|
|
|
end |
|
133
|
|
|
end |
|
134
|
|
|
end |
|
135
|
|
|
|