failbot 1.3.0 → 1.4.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 +4 -4
- data/lib/failbot.rb +71 -0
- data/lib/failbot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f19849426b1157a44d160d8830f3b27c6cb92474
|
4
|
+
data.tar.gz: 60928e3d00961f66514689a7741da5900a7daee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a55e4e99838d44b9be16c0e8e47edb6da56f8a09d54dca7a2179d9bf70cc971c77d2b17ef4182454931f1800359106a599b667676919f9c6cc29602d1ac8c520
|
7
|
+
data.tar.gz: ae4c150bd8b7711b30deceac609149e9d2e7b16930c8377a6534907e6985ffcabef0d50807954f31ae772d6ccac38728557df8516fb0a3c75c53a700667c273e
|
data/lib/failbot.rb
CHANGED
@@ -343,6 +343,10 @@ module Failbot
|
|
343
343
|
'created_at' => Time.now.utc.iso8601(6)
|
344
344
|
}
|
345
345
|
|
346
|
+
if cause = pretty_print_cause(e)
|
347
|
+
res['cause'] = cause
|
348
|
+
end
|
349
|
+
|
346
350
|
if exception_context = (e.respond_to?(:failbot_context) && e.failbot_context)
|
347
351
|
res.merge!(exception_context)
|
348
352
|
end
|
@@ -378,6 +382,73 @@ module Failbot
|
|
378
382
|
Failbot.instrumenter.instrument(name, payload) if Failbot.instrumenter
|
379
383
|
end
|
380
384
|
|
385
|
+
# We'll include this many nested Exception#cause objects in the needle
|
386
|
+
# context. We limit the number of objects to prevent excessive recursion and
|
387
|
+
# large needle contexts.
|
388
|
+
MAXIMUM_CAUSE_DEPTH = 2
|
389
|
+
|
390
|
+
# Pretty-print Exception#cause (and nested causes) for inclusion in needle
|
391
|
+
# context
|
392
|
+
#
|
393
|
+
# e - The Exception object whose #cause should be printed
|
394
|
+
# depth - Integer number of Exception#cause objects to descend into.
|
395
|
+
#
|
396
|
+
# Returns a String.
|
397
|
+
def pretty_print_cause(e, depth = MAXIMUM_CAUSE_DEPTH)
|
398
|
+
return unless depth > 0
|
399
|
+
|
400
|
+
causes = []
|
401
|
+
|
402
|
+
current = e
|
403
|
+
depth.times do
|
404
|
+
pretty_cause = pretty_print_one_cause(current)
|
405
|
+
break unless pretty_cause
|
406
|
+
causes << pretty_cause
|
407
|
+
current = current.cause
|
408
|
+
end
|
409
|
+
|
410
|
+
return if causes.empty?
|
411
|
+
|
412
|
+
result = causes.join("\n\nCAUSED BY:\n\n")
|
413
|
+
|
414
|
+
if current.respond_to?(:cause) && current.cause
|
415
|
+
result << "\n\nFurther #cause backtraces were omitted\n"
|
416
|
+
end
|
417
|
+
|
418
|
+
result
|
419
|
+
end
|
420
|
+
|
421
|
+
# Pretty-print a single Exception#cause
|
422
|
+
#
|
423
|
+
# e - The Exception object whose #cause should be printed
|
424
|
+
#
|
425
|
+
# Returns a String.
|
426
|
+
def pretty_print_one_cause(e)
|
427
|
+
return unless e.respond_to?(:cause)
|
428
|
+
cause = e.cause
|
429
|
+
return unless cause
|
430
|
+
|
431
|
+
result = "#{cause.class.name}: #{cause.message}\n"
|
432
|
+
|
433
|
+
# Find where the cause's backtrace differs from the child exception's.
|
434
|
+
backtrace = Array(e.backtrace)
|
435
|
+
cause_backtrace = Array(cause.backtrace)
|
436
|
+
index = -1
|
437
|
+
while backtrace[index] == cause_backtrace[index]
|
438
|
+
index -= 1
|
439
|
+
end
|
440
|
+
|
441
|
+
# Add on a few common frames to make it clear where the backtraces line up.
|
442
|
+
index += 3
|
443
|
+
index = -1 if index >= 0
|
444
|
+
|
445
|
+
cause_backtrace[0..index].each do |line|
|
446
|
+
result << "\t#{line}\n"
|
447
|
+
end
|
448
|
+
|
449
|
+
result
|
450
|
+
end
|
451
|
+
|
381
452
|
extend self
|
382
453
|
|
383
454
|
# If the library was lazy loaded due to failbot/exit_hook.rb and a delayed
|
data/lib/failbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: failbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@rtomayko"
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yajl-ruby
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: 1.3.6
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.2.
|
110
|
+
rubygems_version: 2.2.3
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Deliver exceptions to Haystack
|