error-handling 1.1 → 1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/error-handling.rb +26 -0
- metadata +1 -1
data/lib/error-handling.rb
CHANGED
@@ -79,4 +79,30 @@ class Error
|
|
79
79
|
end
|
80
80
|
return
|
81
81
|
end
|
82
|
+
|
83
|
+
def load(file_name)
|
84
|
+
#varify the file does inface exist
|
85
|
+
if File.file?(file_name)
|
86
|
+
|
87
|
+
#open error file and read each line.
|
88
|
+
File.open(file_name, "r").each do |file_line|
|
89
|
+
|
90
|
+
#split the items to push individually into the errors array
|
91
|
+
error_split = file_line.split(" ")
|
92
|
+
|
93
|
+
#push errors into the $stored_errors array
|
94
|
+
$stored_errors.push([error_split[1].chop, error_split[2], error_split[0].slice(1..-1).chop])
|
95
|
+
end
|
96
|
+
else
|
97
|
+
puts("Load error: \"" + file_name + "\" does not exist.")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def search(error_type)
|
102
|
+
$stored_errors.each{ |error|
|
103
|
+
if error[0] == error_type
|
104
|
+
puts("[" + error[2] + "] " + error[0] + ": " + error[1])
|
105
|
+
end
|
106
|
+
}
|
107
|
+
end
|
82
108
|
end
|