exception_extensions 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/exception_extensions.gemspec +1 -1
- data/lib/exception_extensions/exception_path_traverser.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 692a23af69f5de4e2695de4157997c929655fc9be32a5361bb63595670e34a9c
|
4
|
+
data.tar.gz: 9c2d7dfe97989c03c7ad38fc7a9a86b89633ffb45c314d48cc832fb14f5a9418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62fe2a11f4396760ecff839fdba595072d313b819c86d0d95b7d0fcd5f6e3fa70447f7562f0a59ee1096f50508c69f9290ee2383830e189bf3bf982a4eddab1
|
7
|
+
data.tar.gz: 4795fee7e9a36cd94fde4b09b3829b3e359b623c08a5022691e9a08ee25cd7005db20d718430e4f32c0d74de27f281c47fc57b4b181acbf30f97c289146f5bd2
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ gem 'exception_extensions'
|
|
24
24
|
## Usage Examples
|
25
25
|
|
26
26
|
### Assume the following operation
|
27
|
-
```
|
27
|
+
```ruby
|
28
28
|
def the_operation
|
29
29
|
# collection of exceptions
|
30
30
|
exceptions = []
|
@@ -47,7 +47,7 @@ end
|
|
47
47
|
```
|
48
48
|
|
49
49
|
### Example1: Calling the_operation directly
|
50
|
-
```
|
50
|
+
```ruby
|
51
51
|
begin
|
52
52
|
the_operation
|
53
53
|
rescue => exc
|
@@ -73,7 +73,7 @@ exception2 message: expected a 1
|
|
73
73
|
```
|
74
74
|
|
75
75
|
### Example2: Calling the_operation indirectly resulting in an exception chain
|
76
|
-
```
|
76
|
+
```ruby
|
77
77
|
# here, we illustrate traversing the exception chain
|
78
78
|
def handle_operations
|
79
79
|
the_operation
|
@@ -118,4 +118,4 @@ exception2 class: ArgumentError
|
|
118
118
|
exception2 message: expected a 1
|
119
119
|
JOINED: "Unable to handle operations => multiple exceptions occurred during the_operation => expected a 1"
|
120
120
|
|
121
|
-
```
|
121
|
+
```
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'exception_extensions'
|
3
|
-
gem.version = '1.0.
|
3
|
+
gem.version = '1.0.2'
|
4
4
|
gem.date = '2019-11-27'
|
5
5
|
gem.summary = 'Useful extensions for Ruby Exceptions'
|
6
6
|
gem.description = 'Useful extensions for Ruby Exceptions; Adds support for Exceptions with multiple causes (useful when executing fan-out operations) and Exception cause traversal.'
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module ExceptionExtensions
|
2
2
|
class ExceptionPathTraverser < ExceptionTraverser
|
3
3
|
def each(&block)
|
4
|
-
|
5
|
-
|
4
|
+
if block_given?
|
5
|
+
return if @exception.nil?
|
6
|
+
each_internal(@exception, [], &block)
|
7
|
+
else
|
8
|
+
to_enum(:each)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
private
|
@@ -22,4 +26,4 @@ module ExceptionExtensions
|
|
22
26
|
path.pop
|
23
27
|
end
|
24
28
|
end
|
25
|
-
end
|
29
|
+
end
|