squash_ruby 1.1.1 → 1.2.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.
- data/lib/squash/ruby.rb +43 -0
- metadata +29 -29
data/lib/squash/ruby.rb
CHANGED
@@ -152,6 +152,7 @@ module Squash
|
|
152
152
|
# ignore. If not provided, ignores all exceptions raised in the block.
|
153
153
|
# @yield The code to ignore exceptions in.
|
154
154
|
# @return The result of the block.
|
155
|
+
# @raise [ArgumentError] If no block is provided.
|
155
156
|
|
156
157
|
def self.ignore_exceptions(exception_classes=nil)
|
157
158
|
raise ArgumentError, "Squash::Ruby.ignore_exceptions must be called with a block" unless block_given?
|
@@ -185,6 +186,48 @@ module Squash
|
|
185
186
|
end
|
186
187
|
end
|
187
188
|
|
189
|
+
# @overload fail_silently(exception_classes=nil, options={})
|
190
|
+
# Executes the block, suppressing and silently reporting any exceptions to
|
191
|
+
# Squash. This allows you to ensure that a non-critical block of code
|
192
|
+
# does not halt your application while still receiving exception
|
193
|
+
# notifications in Squash.
|
194
|
+
# @param [Array<Class>] exception_classes A list of exception classes to
|
195
|
+
# report silently. Exceptions _not_ of these classes (or their
|
196
|
+
# subclasses) will raise (and presumably be handled by Squash elsewhere
|
197
|
+
# in your code).
|
198
|
+
# @param [Hash] options Additional options to pass to {.notify}.
|
199
|
+
# @yield The code to suppress exceptions in.
|
200
|
+
# @return The result of the block.
|
201
|
+
# @raise [ArgumentError] If no block is provided.
|
202
|
+
|
203
|
+
def self.fail_silently(exception_classes_or_options=nil, options=nil)
|
204
|
+
raise ArgumentError, "Squash::Ruby.exception_classes must be called with a block" unless block_given?
|
205
|
+
|
206
|
+
exception_classes = if options
|
207
|
+
exception_classes_or_options
|
208
|
+
else
|
209
|
+
if exception_classes_or_options.kind_of?(Hash) then
|
210
|
+
options = exception_classes_or_options
|
211
|
+
nil
|
212
|
+
else
|
213
|
+
exception_classes_or_options
|
214
|
+
end
|
215
|
+
end
|
216
|
+
options ||= {}
|
217
|
+
|
218
|
+
exception_classes = [exception_classes] if exception_classes.kind_of?(Class)
|
219
|
+
|
220
|
+
begin
|
221
|
+
yield
|
222
|
+
rescue Object => err
|
223
|
+
if exception_classes.nil? || exception_classes.detect { |e| err.kind_of?(e) }
|
224
|
+
Squash::Ruby.notify err, options
|
225
|
+
else
|
226
|
+
raise
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
188
231
|
# Sets configuration options for the client from a hash. See the README for
|
189
232
|
# a list of configuration options. Subsequent calls will merge in new
|
190
233
|
# configuration options.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squash_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Morgan
|
@@ -15,10 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-04-23 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
23
|
none: false
|
23
24
|
requirements:
|
24
25
|
- - ">="
|
@@ -27,12 +28,12 @@ dependencies:
|
|
27
28
|
segments:
|
28
29
|
- 0
|
29
30
|
version: "0"
|
30
|
-
|
31
|
-
name: json
|
31
|
+
requirement: *id001
|
32
32
|
prerelease: false
|
33
|
-
|
33
|
+
name: json
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
37
|
none: false
|
37
38
|
requirements:
|
38
39
|
- - ">="
|
@@ -41,12 +42,12 @@ dependencies:
|
|
41
42
|
segments:
|
42
43
|
- 0
|
43
44
|
version: "0"
|
44
|
-
|
45
|
-
name: rspec
|
45
|
+
requirement: *id002
|
46
46
|
prerelease: false
|
47
|
-
|
47
|
+
name: rspec
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
49
|
+
type: :development
|
50
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
50
51
|
none: false
|
51
52
|
requirements:
|
52
53
|
- - ">="
|
@@ -55,12 +56,12 @@ dependencies:
|
|
55
56
|
segments:
|
56
57
|
- 0
|
57
58
|
version: "0"
|
58
|
-
|
59
|
-
name: fakefs
|
59
|
+
requirement: *id003
|
60
60
|
prerelease: false
|
61
|
-
|
61
|
+
name: fakefs
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
63
|
+
type: :development
|
64
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
64
65
|
none: false
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
@@ -69,12 +70,12 @@ dependencies:
|
|
69
70
|
segments:
|
70
71
|
- 0
|
71
72
|
version: "0"
|
72
|
-
|
73
|
-
name: yard
|
73
|
+
requirement: *id004
|
74
74
|
prerelease: false
|
75
|
-
|
75
|
+
name: yard
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
|
-
|
77
|
+
type: :development
|
78
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
78
79
|
none: false
|
79
80
|
requirements:
|
80
81
|
- - ">="
|
@@ -83,12 +84,12 @@ dependencies:
|
|
83
84
|
segments:
|
84
85
|
- 0
|
85
86
|
version: "0"
|
86
|
-
|
87
|
-
name: redcarpet
|
87
|
+
requirement: *id005
|
88
88
|
prerelease: false
|
89
|
-
|
89
|
+
name: redcarpet
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
|
-
|
91
|
+
type: :development
|
92
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
92
93
|
none: false
|
93
94
|
requirements:
|
94
95
|
- - ">="
|
@@ -97,10 +98,9 @@ dependencies:
|
|
97
98
|
segments:
|
98
99
|
- 0
|
99
100
|
version: "0"
|
100
|
-
|
101
|
-
name: jeweler
|
101
|
+
requirement: *id006
|
102
102
|
prerelease: false
|
103
|
-
|
103
|
+
name: jeweler
|
104
104
|
description: This client library records Ruby exceptions to Squash.
|
105
105
|
email: tim@squareup.com
|
106
106
|
executables: []
|