eh 0.0.8 → 1.0.0
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -5
- data/eh.gemspec +3 -3
- data/lib/eh/version.rb +1 -1
- data/spec/eh_spec.rb +64 -64
- data/spec/spec_helper.rb +1 -1
- metadata +76 -95
- data/backlog +0 -78
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4bfd804b161c51f29a99084c06c275b3c1e1db47
|
4
|
+
data.tar.gz: eeaf921eb9cd1746ac8c5e5f482b460920b81a4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f6e3feba9c429e10e6b084b3f1c5a63477f1e8fd161a2cf5b86e4aa8d9f8af030577d77b38955bf924ad92c083b7f752f0d8c171c934ed6b59ea65a53afe203
|
7
|
+
data.tar.gz: 0f7b40f362363c4328b4e56049563bf174c6c940f123fed8cc96d7ac676e936f9da91b94b154832440033f9b988ab6bcc3e1637a675bfb5eae86ae6af9cbd494
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ o Unhandled exceptions can be logged and emailed in main() using EH::report_unha
|
|
25
25
|
|
26
26
|
o A list of handlers can be injected to do custom handling, such as email, roll-back, etc.
|
27
27
|
|
28
|
-
This gem
|
28
|
+
This gem was sponsored by Hetzner (Pty) Ltd - http://hetzner.co.za
|
29
29
|
|
30
30
|
## Installation
|
31
31
|
|
@@ -112,15 +112,13 @@ All exceptions are passed to all handlers, regardless of exception filter. It is
|
|
112
112
|
Unhandled exceptions can be logged and emailed as follows:
|
113
113
|
|
114
114
|
at_exit do
|
115
|
-
EH::report_unhandled(logfile = "/var/log/myapp/crash.log", email = "
|
115
|
+
EH::report_unhandled(logfile = "/var/log/myapp/crash.log", email = "ernstvangraan@gmail.com")
|
116
116
|
exit EH::EX_CONFIG
|
117
117
|
end
|
118
118
|
|
119
119
|
Please send feedback and comments to the authors at:
|
120
120
|
|
121
|
-
Ernst van Graan <
|
122
|
-
|
123
|
-
Wynand van Dyk <wynand.van.dyk@hetzner.co.za>
|
121
|
+
Ernst van Graan <ernstvangraan@gmail>
|
124
122
|
|
125
123
|
## Contributing
|
126
124
|
|
data/eh.gemspec
CHANGED
@@ -6,11 +6,11 @@ require 'eh/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "eh"
|
8
8
|
spec.version = ErrorHandler::VERSION
|
9
|
-
spec.authors = ["Ernst van Graan
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Ernst van Graan"]
|
10
|
+
spec.email = ["ernstvangraan@gmail.com"]
|
11
11
|
spec.description = %q{Error handler gem that allows wrapping of code blocks with support for block retry, logging, exception filtering and re-raise}
|
12
12
|
spec.summary = %q{Error handler gem that allows wrapping of code blocks with support for block retry, logging, exception filtering and re-raise}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/evangraan/eh"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/eh/version.rb
CHANGED
data/spec/eh_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe ErrorHandler do
|
|
20
20
|
rescue => e
|
21
21
|
exception = e
|
22
22
|
end
|
23
|
-
exception.nil
|
23
|
+
expect(exception.nil?).to eq(true)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not retry" do
|
@@ -32,11 +32,11 @@ describe ErrorHandler do
|
|
32
32
|
end
|
33
33
|
rescue => e
|
34
34
|
end
|
35
|
-
count.
|
35
|
+
expect(count).to eq(1)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should log the message specified with the exception appended, using the logger specified" do
|
39
|
-
@logger.
|
39
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
40
40
|
begin
|
41
41
|
EH::run(:logger => @logger, :message => "the message") do
|
42
42
|
raise RuntimeError
|
@@ -45,7 +45,7 @@ describe ErrorHandler do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should inform all handlers specified of the message and exception" do
|
48
|
-
@mailer.
|
48
|
+
expect(@mailer).to receive(:handle)
|
49
49
|
@handler2 = MockMailer.new
|
50
50
|
begin
|
51
51
|
EH::run(:handlers => [@mailer, @handler2], :message => "the message") do
|
@@ -53,8 +53,8 @@ describe ErrorHandler do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
@handler2.e.class.
|
57
|
-
@handler2.msg.
|
56
|
+
expect(@handler2.e.class).to eq(RuntimeError)
|
57
|
+
expect(@handler2.msg).to eq("the message: RuntimeError")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should inform a specified handler of the message and exception" do
|
@@ -64,12 +64,12 @@ describe ErrorHandler do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
@mailer.e.class.
|
68
|
-
@mailer.msg.
|
67
|
+
expect(@mailer.e.class).to eq(RuntimeError)
|
68
|
+
expect(@mailer.msg).to eq("the message: RuntimeError")
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should log the message specified with the exception appended, if the exception is in :exception_filter, using the logger specified" do
|
72
|
-
@logger.
|
72
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
73
73
|
begin
|
74
74
|
EH::run(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
75
75
|
raise RuntimeError
|
@@ -78,7 +78,7 @@ describe ErrorHandler do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not log, if :exception_filter is specified and the exception is not in :exception_filter" do
|
81
|
-
@logger.
|
81
|
+
expect(@logger).not_to receive(:error)
|
82
82
|
begin
|
83
83
|
EH::run(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
84
84
|
raise IOError
|
@@ -87,7 +87,7 @@ describe ErrorHandler do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should log using the level specified" do
|
90
|
-
@logger.
|
90
|
+
expect(@logger).to receive(:warn).with("the message: RuntimeError")
|
91
91
|
begin
|
92
92
|
EH::run(:logger => @logger, :message => "the message", :level => EH::WARN) do
|
93
93
|
raise RuntimeError
|
@@ -106,7 +106,7 @@ describe ErrorHandler do
|
|
106
106
|
rescue => e
|
107
107
|
exception = e
|
108
108
|
end
|
109
|
-
exception.class.
|
109
|
+
expect(exception.class).to eq(RuntimeError)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should re-raise all exceptions if asked to (no exception filter provided)" do
|
@@ -118,7 +118,7 @@ describe ErrorHandler do
|
|
118
118
|
rescue => e
|
119
119
|
exception = e
|
120
120
|
end
|
121
|
-
exception.class.
|
121
|
+
expect(exception.class).to eq(RuntimeError)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should re-raise all exceptions if asked to (empty exception filter provided)" do
|
@@ -130,7 +130,7 @@ describe ErrorHandler do
|
|
130
130
|
rescue => e
|
131
131
|
exception = e
|
132
132
|
end
|
133
|
-
exception.class.
|
133
|
+
expect(exception.class).to eq(RuntimeError)
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should not retry" do
|
@@ -142,11 +142,11 @@ describe ErrorHandler do
|
|
142
142
|
end
|
143
143
|
rescue => e
|
144
144
|
end
|
145
|
-
count.
|
145
|
+
expect(count).to eq(1)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should log the message specified with the exception appended, using the logger specified" do
|
149
|
-
@logger.
|
149
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
150
150
|
begin
|
151
151
|
EH::run!(:logger => @logger, :message => "the message") do
|
152
152
|
raise RuntimeError
|
@@ -156,7 +156,7 @@ describe ErrorHandler do
|
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should inform all handlers specified of the message and exception" do
|
159
|
-
@mailer.
|
159
|
+
expect(@mailer).to receive(:handle)
|
160
160
|
@handler2 = MockMailer.new
|
161
161
|
begin
|
162
162
|
EH::run(:handlers => [@mailer, @handler2], :message => "the message") do
|
@@ -165,8 +165,8 @@ describe ErrorHandler do
|
|
165
165
|
rescue => e
|
166
166
|
end
|
167
167
|
|
168
|
-
@handler2.e.class.
|
169
|
-
@handler2.msg.
|
168
|
+
expect(@handler2.e.class).to eq(RuntimeError)
|
169
|
+
expect(@handler2.msg).to eq("the message: RuntimeError")
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should inform a specified handler of the message and exception" do
|
@@ -177,12 +177,12 @@ describe ErrorHandler do
|
|
177
177
|
rescue => e
|
178
178
|
end
|
179
179
|
|
180
|
-
@mailer.e.class.
|
181
|
-
@mailer.msg.
|
180
|
+
expect(@mailer.e.class).to eq(RuntimeError)
|
181
|
+
expect(@mailer.msg).to eq("the message: RuntimeError")
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should log the message specified with the exception appended, if the exception is in :exception_filter, using the logger specified" do
|
185
|
-
@logger.
|
185
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
186
186
|
begin
|
187
187
|
EH::run!(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
188
188
|
raise RuntimeError
|
@@ -192,7 +192,7 @@ describe ErrorHandler do
|
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should not log, if :exception_filter is specified and the exception is not in :exception_filter" do
|
195
|
-
@logger.
|
195
|
+
expect(@logger).not_to receive(:error)
|
196
196
|
begin
|
197
197
|
EH::run!(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
198
198
|
raise IOError
|
@@ -202,7 +202,7 @@ describe ErrorHandler do
|
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should log using the level specified" do
|
205
|
-
@logger.
|
205
|
+
expect(@logger).to receive(:warn).with("the message: RuntimeError")
|
206
206
|
begin
|
207
207
|
EH::run!(:logger => @logger, :message => "the message", :level => EH::WARN) do
|
208
208
|
raise RuntimeError
|
@@ -224,7 +224,7 @@ describe ErrorHandler do
|
|
224
224
|
rescue => e
|
225
225
|
exception = e
|
226
226
|
end
|
227
|
-
exception.nil
|
227
|
+
expect(exception.nil?).to eq(true)
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should retry" do
|
@@ -235,7 +235,7 @@ describe ErrorHandler do
|
|
235
235
|
raise RuntimeError
|
236
236
|
end
|
237
237
|
end
|
238
|
-
count.
|
238
|
+
expect(count).to eq(3)
|
239
239
|
end
|
240
240
|
|
241
241
|
it "should return true if the code succeeds after retry" do
|
@@ -246,7 +246,7 @@ describe ErrorHandler do
|
|
246
246
|
raise RuntimeError if count < 2
|
247
247
|
end
|
248
248
|
end
|
249
|
-
result.
|
249
|
+
expect(result).to eq(true)
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should return false if the code does not succeed after retry" do
|
@@ -255,7 +255,7 @@ describe ErrorHandler do
|
|
255
255
|
raise RuntimeError
|
256
256
|
end
|
257
257
|
end
|
258
|
-
result.
|
258
|
+
expect(result).to eq(false)
|
259
259
|
end
|
260
260
|
|
261
261
|
it "should attempt the number of retries specified in :threshold" do
|
@@ -266,7 +266,7 @@ describe ErrorHandler do
|
|
266
266
|
raise RuntimeError
|
267
267
|
end
|
268
268
|
end
|
269
|
-
count.
|
269
|
+
expect(count).to eq(5)
|
270
270
|
end
|
271
271
|
|
272
272
|
it "should delay between intervals as specified in :delay" do
|
@@ -277,11 +277,11 @@ describe ErrorHandler do
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
post = Time.now
|
280
|
-
(post - pre > 0.6).
|
280
|
+
expect(post - pre > 0.6).to eq(true)
|
281
281
|
end
|
282
282
|
|
283
283
|
it "should log the message specified with the exception appended, using the logger specified" do
|
284
|
-
@logger.
|
284
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
285
285
|
begin
|
286
286
|
EH::retry(:logger => @logger, :message => "the message") do
|
287
287
|
raise RuntimeError
|
@@ -290,7 +290,7 @@ describe ErrorHandler do
|
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should inform all handlers specified of the message and exception" do
|
293
|
-
@mailer.
|
293
|
+
expect(@mailer).to receive(:handle)
|
294
294
|
@handler2 = MockMailer.new
|
295
295
|
begin
|
296
296
|
EH::run(:handlers => [@mailer, @handler2], :message => "the message") do
|
@@ -298,8 +298,8 @@ describe ErrorHandler do
|
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
301
|
-
@handler2.e.class.
|
302
|
-
@handler2.msg.
|
301
|
+
expect(@handler2.e.class).to eq(RuntimeError)
|
302
|
+
expect(@handler2.msg).to eq("the message: RuntimeError")
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should inform a specified handler of the message and exception" do
|
@@ -309,12 +309,12 @@ describe ErrorHandler do
|
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
@mailer.e.class.
|
313
|
-
@mailer.msg.
|
312
|
+
expect(@mailer.e.class).to eq(RuntimeError)
|
313
|
+
expect(@mailer.msg).to eq("the message: RuntimeError")
|
314
314
|
end
|
315
315
|
|
316
316
|
it "should log the message specified with the exception appended, if the exception is in :exception_filter, using the logger specified" do
|
317
|
-
@logger.
|
317
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
318
318
|
begin
|
319
319
|
EH::retry(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
320
320
|
raise RuntimeError
|
@@ -323,7 +323,7 @@ describe ErrorHandler do
|
|
323
323
|
end
|
324
324
|
|
325
325
|
it "should not log, if :exception_filter is specified and the exception is not in :exception_filter" do
|
326
|
-
@logger.
|
326
|
+
expect(@logger).not_to receive(:error)
|
327
327
|
begin
|
328
328
|
EH::retry(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
329
329
|
raise IOError
|
@@ -332,7 +332,7 @@ describe ErrorHandler do
|
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should log using the level specified" do
|
335
|
-
@logger.
|
335
|
+
expect(@logger).to receive(:warn).with("the message: RuntimeError")
|
336
336
|
begin
|
337
337
|
EH::retry(:logger => @logger, :message => "the message", :level => EH::WARN) do
|
338
338
|
raise RuntimeError
|
@@ -351,7 +351,7 @@ describe ErrorHandler do
|
|
351
351
|
rescue => e
|
352
352
|
exception = e
|
353
353
|
end
|
354
|
-
exception.class.
|
354
|
+
expect(exception.class).to eq(RuntimeError)
|
355
355
|
end
|
356
356
|
|
357
357
|
it "should retry" do
|
@@ -363,7 +363,7 @@ describe ErrorHandler do
|
|
363
363
|
end
|
364
364
|
rescue => e
|
365
365
|
end
|
366
|
-
count.
|
366
|
+
expect(count).to eq(3)
|
367
367
|
end
|
368
368
|
|
369
369
|
it "should attempt the number of retries specified in :threshold" do
|
@@ -375,7 +375,7 @@ describe ErrorHandler do
|
|
375
375
|
end
|
376
376
|
rescue => e
|
377
377
|
end
|
378
|
-
count.
|
378
|
+
expect(count).to eq(5)
|
379
379
|
end
|
380
380
|
|
381
381
|
it "should delay between intervals as specified in :delay" do
|
@@ -387,11 +387,11 @@ describe ErrorHandler do
|
|
387
387
|
rescue => e
|
388
388
|
end
|
389
389
|
post = Time.now
|
390
|
-
(post - pre > 0.6).
|
390
|
+
expect(post - pre > 0.6).to eq(true)
|
391
391
|
end
|
392
392
|
|
393
393
|
it "should log the message specified with the exception appended, using the logger specified" do
|
394
|
-
@logger.
|
394
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
395
395
|
begin
|
396
396
|
EH::retry!(:logger => @logger, :message => "the message") do
|
397
397
|
raise RuntimeError
|
@@ -401,7 +401,7 @@ describe ErrorHandler do
|
|
401
401
|
end
|
402
402
|
|
403
403
|
it "should inform all handlers specified of the message and exception" do
|
404
|
-
@mailer.
|
404
|
+
expect(@mailer).to receive(:handle)
|
405
405
|
@handler2 = MockMailer.new
|
406
406
|
begin
|
407
407
|
EH::run(:handlers => [@mailer, @handler2], :message => "the message") do
|
@@ -410,8 +410,8 @@ describe ErrorHandler do
|
|
410
410
|
rescue => e
|
411
411
|
end
|
412
412
|
|
413
|
-
@handler2.e.class.
|
414
|
-
@handler2.msg.
|
413
|
+
expect(@handler2.e.class).to eq(RuntimeError)
|
414
|
+
expect(@handler2.msg).to eq("the message: RuntimeError")
|
415
415
|
end
|
416
416
|
|
417
417
|
it "should inform a specified handler of the message and exception" do
|
@@ -422,12 +422,12 @@ describe ErrorHandler do
|
|
422
422
|
rescue => e
|
423
423
|
end
|
424
424
|
|
425
|
-
@mailer.e.class.
|
426
|
-
@mailer.msg.
|
425
|
+
expect(@mailer.e.class).to eq(RuntimeError)
|
426
|
+
expect(@mailer.msg).to eq("the message: RuntimeError")
|
427
427
|
end
|
428
428
|
|
429
429
|
it "should log the message specified with the exception appended, if the exception is in :exception_filter, using the logger specified" do
|
430
|
-
@logger.
|
430
|
+
expect(@logger).to receive(:error).with("the message: RuntimeError")
|
431
431
|
begin
|
432
432
|
EH::retry!(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
433
433
|
raise RuntimeError
|
@@ -437,7 +437,7 @@ describe ErrorHandler do
|
|
437
437
|
end
|
438
438
|
|
439
439
|
it "should not log, if :exception_filter is specified and the exception is not in :exception_filter" do
|
440
|
-
@logger.
|
440
|
+
expect(@logger).not_to receive(:error)
|
441
441
|
begin
|
442
442
|
EH::retry!(:logger => @logger, :message => "the message", :exception_filter => [RuntimeError]) do
|
443
443
|
raise IOError
|
@@ -447,7 +447,7 @@ describe ErrorHandler do
|
|
447
447
|
end
|
448
448
|
|
449
449
|
it "should log using the level specified" do
|
450
|
-
@logger.
|
450
|
+
expect(@logger).to receive(:warn).with("the message: RuntimeError")
|
451
451
|
begin
|
452
452
|
EH::retry!(:logger => @logger, :message => "the message", :level => EH::WARN) do
|
453
453
|
raise RuntimeError
|
@@ -460,46 +460,46 @@ describe ErrorHandler do
|
|
460
460
|
|
461
461
|
context "when asked to log" do
|
462
462
|
it "should log to a single logger provided, with the message specified, at the level specified" do
|
463
|
-
@logger.
|
463
|
+
expect(@logger).to receive(:info).with("testing single logging")
|
464
464
|
EH::log(@logger, "testing single logging", EH::INFO)
|
465
465
|
end
|
466
466
|
|
467
467
|
it "should log to a single logger provided, with the message specified, at the level specified" do
|
468
468
|
@logger2 = MockLogger.new
|
469
469
|
|
470
|
-
@logger.
|
471
|
-
@logger2.
|
470
|
+
expect(@logger).to receive(:debug).with("testing single logging")
|
471
|
+
expect(@logger2).to receive(:debug).with("testing single logging")
|
472
472
|
EH::log([@logger, @logger2], "testing single logging", EH::DEBUG)
|
473
473
|
end
|
474
474
|
|
475
475
|
it "should log at all log levels" do
|
476
|
-
@logger.
|
476
|
+
expect(@logger).to receive(:info)
|
477
477
|
EH::log(@logger, "info", EH::INFO)
|
478
478
|
|
479
|
-
@logger.
|
479
|
+
expect(@logger).to receive(:debug)
|
480
480
|
EH::log(@logger, "debug", EH::DEBUG)
|
481
481
|
|
482
|
-
@logger.
|
482
|
+
expect(@logger).to receive(:error)
|
483
483
|
EH::log(@logger, "error", EH::ERROR)
|
484
484
|
|
485
|
-
@logger.
|
485
|
+
expect(@logger).to receive(:warn)
|
486
486
|
EH::log(@logger, "warn", EH::WARN)
|
487
487
|
|
488
|
-
@logger.
|
488
|
+
expect(@logger).to receive(:fatal)
|
489
489
|
EH::log(@logger, "fatal", EH::FATAL)
|
490
490
|
end
|
491
491
|
|
492
492
|
it "should log using 'warn' if a nil single logger is provided" do
|
493
|
-
EH
|
493
|
+
expect(EH).to receive(:warn).with "fatal: fatal"
|
494
494
|
|
495
495
|
EH::log(nil, "fatal", EH::FATAL)
|
496
496
|
end
|
497
497
|
|
498
498
|
it "should not log if nil is provided in a list of loggers, and 'warn' should not be called" do
|
499
|
-
@logger
|
500
|
-
EH
|
499
|
+
expect(@logger).to receive(:fatal).once().with "fatal"
|
500
|
+
expect(EH).not_to receive(:warn)
|
501
501
|
|
502
502
|
EH::log([nil, @logger], "fatal", EH::FATAL)
|
503
503
|
end
|
504
504
|
end
|
505
|
-
end
|
505
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'eh'))
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
7
|
+
#config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
8
|
config.run_all_when_everything_filtered = true
|
9
9
|
config.filter_run :focus
|
10
10
|
|
metadata
CHANGED
@@ -1,96 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: eh
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
- Ernst van Graan
|
6
|
+
authors:
|
7
|
+
- Ernst van Graan
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: bundler
|
22
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
23
20
|
type: :development
|
24
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
|
-
version: "1.3"
|
34
|
-
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rake
|
37
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
38
34
|
type: :development
|
39
|
-
|
40
|
-
|
41
|
-
requirements:
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
42
38
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 0
|
47
|
-
version: "0"
|
48
|
-
requirement: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
50
42
|
name: rspec
|
51
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
52
48
|
type: :development
|
53
|
-
|
54
|
-
|
55
|
-
requirements:
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
56
52
|
- - ">="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
- 0
|
61
|
-
version: "0"
|
62
|
-
requirement: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
64
56
|
name: simplecov
|
65
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
66
62
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
requirements:
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
70
66
|
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
description: Error handler gem that allows wrapping of code blocks with support for block retry, logging, exception filtering and re-raise
|
78
|
-
email:
|
79
|
-
- ernst.van.graan@hetzner.co.za
|
80
|
-
- wynand.van.dyk@hetzner.co.za
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Error handler gem that allows wrapping of code blocks with support for
|
70
|
+
block retry, logging, exception filtering and re-raise
|
71
|
+
email:
|
72
|
+
- ernstvangraan@gmail.com
|
81
73
|
executables: []
|
82
|
-
|
83
74
|
extensions: []
|
84
|
-
|
85
75
|
extra_rdoc_files: []
|
86
|
-
|
87
|
-
|
88
|
-
- .gitignore
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
89
78
|
- Gemfile
|
90
79
|
- LICENSE.txt
|
91
80
|
- README.md
|
92
81
|
- Rakefile
|
93
|
-
- backlog
|
94
82
|
- eh.gemspec
|
95
83
|
- lib/eh/eh.rb
|
96
84
|
- lib/eh/version.rb
|
@@ -99,41 +87,34 @@ files:
|
|
99
87
|
- spec/mock_logger.rb
|
100
88
|
- spec/mock_mailer.rb
|
101
89
|
- spec/spec_helper.rb
|
102
|
-
homepage:
|
103
|
-
licenses:
|
90
|
+
homepage: https://github.com/evangraan/eh
|
91
|
+
licenses:
|
104
92
|
- MIT
|
93
|
+
metadata: {}
|
105
94
|
post_install_message:
|
106
95
|
rdoc_options: []
|
107
|
-
|
108
|
-
require_paths:
|
96
|
+
require_paths:
|
109
97
|
- lib
|
110
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
-
|
112
|
-
requirements:
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
113
100
|
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
version: "0"
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
|
-
requirements:
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
122
105
|
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
|
125
|
-
segments:
|
126
|
-
- 0
|
127
|
-
version: "0"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
128
108
|
requirements: []
|
129
|
-
|
130
109
|
rubyforge_project:
|
131
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.4.8
|
132
111
|
signing_key:
|
133
|
-
specification_version:
|
134
|
-
summary: Error handler gem that allows wrapping of code blocks with support for block
|
135
|
-
|
112
|
+
specification_version: 4
|
113
|
+
summary: Error handler gem that allows wrapping of code blocks with support for block
|
114
|
+
retry, logging, exception filtering and re-raise
|
115
|
+
test_files:
|
136
116
|
- spec/eh_spec.rb
|
137
117
|
- spec/mock_logger.rb
|
138
118
|
- spec/mock_mailer.rb
|
139
119
|
- spec/spec_helper.rb
|
120
|
+
has_rdoc:
|
data/backlog
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
class Main
|
2
|
-
def initialize
|
3
|
-
EH::run!(:message=> "constructor should not fail!", :logger => MyLogger.new, :handlers => ImportantErrorHandler.new) do
|
4
|
-
some_bugg_initialzation
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
class TestMe
|
11
|
-
def something
|
12
|
-
EH::push(:context => "super important")
|
13
|
-
|
14
|
-
EH::retry!() do
|
15
|
-
some_buggy_code
|
16
|
-
end
|
17
|
-
|
18
|
-
EH::pop(:context)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def easy_to_use
|
23
|
-
EH::in_order_to({:do => "something",
|
24
|
-
:given_that => "some state",
|
25
|
-
:note => "i am doing X with #{y}",
|
26
|
-
:error_handler => {:log_to => MyLogger.bnew, :mail_to => "helpme.com"}}) do
|
27
|
-
code_a
|
28
|
-
code_b
|
29
|
-
code_c
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class MySystemApiBoundary
|
34
|
-
def talk_to_another_system(system, message)
|
35
|
-
pkg = EH::package_context
|
36
|
-
message["in_reference_to"] = pkg
|
37
|
-
system.api_method(message)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
... then package across system boundaries
|
48
|
-
|
49
|
-
class ContextDic..
|
50
|
-
|
51
|
-
module EH
|
52
|
-
class EH
|
53
|
-
def self.handle(context, e, env)
|
54
|
-
contexts[context].handle(e, env, context_stack)
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.run(context) do
|
58
|
-
?? << context
|
59
|
-
|
60
|
-
yield
|
61
|
-
|
62
|
-
>>
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
complex_reg_task_abc do
|
69
|
-
myabc
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
EH::in_order_to({:do => "fullfil domain order",
|
76
|
-
:given_that => "account deos not exist" ... ).remember("i am creationg an account using #{blah}").and_if_something_goes_wrong(:mailmeat => "a@me.com") do
|
77
|
-
|
78
|
-
end
|