error-handling 1.2 → 1.3
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 +29 -17
- metadata +5 -5
data/lib/error-handling.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class ErrorHandling
|
2
2
|
#global errors array
|
3
3
|
$stored_errors = Array.new()
|
4
4
|
|
@@ -17,21 +17,27 @@ class Error
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def display(display_errors_ammount)
|
20
|
-
if
|
21
|
-
if
|
22
|
-
|
23
|
-
|
20
|
+
if $stored_errors.length > 0
|
21
|
+
if display_errors_ammount.kind_of? Integer
|
22
|
+
if $stored_errors.length > display_errors_ammount
|
23
|
+
#display error
|
24
|
+
print($stored_errors[display_errors_ammount][0] + ": " + $stored_errors[display_errors_ammount][1])
|
25
|
+
else
|
26
|
+
puts("Invalid error syntax, invalid error number.")
|
27
|
+
end
|
28
|
+
elsif display_errors_ammount == 'last'
|
29
|
+
print($stored_errors[$stored_errors.length - 1][0] + ": " + $stored_errors[$stored_errors.length - 1][1])
|
30
|
+
|
24
31
|
else
|
25
|
-
|
32
|
+
if display_errors_ammount == 'all'
|
33
|
+
#loop through and disply the errors
|
34
|
+
$stored_errors.each{ |indiviual_error|
|
35
|
+
puts("[" + indiviual_error[2].to_s + "] " + indiviual_error[0] + ": " + indiviual_error[1])
|
36
|
+
}
|
37
|
+
end
|
26
38
|
end
|
27
39
|
else
|
28
|
-
|
29
|
-
|
30
|
-
#loop through and disply the errors
|
31
|
-
$stored_errors.each{ |indiviual_error|
|
32
|
-
puts("[" + indiviual_error[2].to_s + "] " + indiviual_error[0] + ": " + indiviual_error[1])
|
33
|
-
}
|
34
|
-
end
|
40
|
+
puts("No errors are currently being stored,")
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -80,21 +86,27 @@ class Error
|
|
80
86
|
return
|
81
87
|
end
|
82
88
|
|
83
|
-
def load(
|
89
|
+
def load(*load_file)
|
84
90
|
#varify the file does inface exist
|
85
|
-
if File.file?(
|
91
|
+
if File.file?(load_file[0])
|
86
92
|
|
87
93
|
#open error file and read each line.
|
88
|
-
File.open(
|
94
|
+
File.open(load_file[0], "r").each do |file_line|
|
89
95
|
|
90
96
|
#split the items to push individually into the errors array
|
91
97
|
error_split = file_line.split(" ")
|
92
98
|
|
93
99
|
#push errors into the $stored_errors array
|
94
100
|
$stored_errors.push([error_split[1].chop, error_split[2], error_split[0].slice(1..-1).chop])
|
101
|
+
|
102
|
+
#check for confirmation parameter
|
103
|
+
if load_file[1] and load_file[1] == 'confirm'
|
104
|
+
puts("External errors file loaded.")
|
105
|
+
end
|
106
|
+
|
95
107
|
end
|
96
108
|
else
|
97
|
-
puts("Load error: \"" +
|
109
|
+
puts("Load error: \"" + load_file[0] + "\" does not exist.")
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: error-handling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Gem designed to improve error handling throughout your Ruby applications.
|
15
15
|
email:
|
@@ -18,7 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/error-handling.rb
|
21
|
-
homepage:
|
21
|
+
homepage: https://github.com/mrpteo/Error-Handling
|
22
22
|
licenses:
|
23
23
|
- MIT
|
24
24
|
post_install_message:
|
@@ -39,8 +39,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
41
|
rubyforge_project:
|
42
|
-
rubygems_version: 1.8.
|
42
|
+
rubygems_version: 1.8.28
|
43
43
|
signing_key:
|
44
44
|
specification_version: 3
|
45
|
-
summary: Beautiful error handling.
|
45
|
+
summary: Beautiful solution to error handling.
|
46
46
|
test_files: []
|