asana_exception_notifier 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -59
- data/examples/sinatra/Gemfile.lock +1 -1
- data/lib/asana_exception_notifier/classes/error_page.rb +1 -1
- data/lib/asana_exception_notifier/version.rb +2 -2
- data/lib/generators/asana_exception_notifier/templates/asana_exception_notifier.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ade21e6641573c0d132b3b869bc701cba29a03f
|
4
|
+
data.tar.gz: be5b38ffd6b55ebf9625d625634179c7ea053559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd3e811cec125c3bcf01aab5b2290cf4bb593e87604ffff86fd46d86c04591353b590d64a4ac350f838d638ec57abc2eef7c519ad86cb5e9dd79ce045a3f30a
|
7
|
+
data.tar.gz: 22ff489240f9ae9118bc66acd1560eb9b541bcd2c1c2574db4074533519c83043c837fdd7632c20f4e93c533b2121c4e0d2abb7b9cb5c9181138ab07f2cf62a5
|
data/README.md
CHANGED
@@ -39,7 +39,69 @@ Add the following to your Gemfile :
|
|
39
39
|
gem "asana_exception_notifier"
|
40
40
|
```
|
41
41
|
|
42
|
-
|
42
|
+
### Rails
|
43
|
+
|
44
|
+
If you are settting up for the first time this gem, just run the following command from the terminal:
|
45
|
+
|
46
|
+
```
|
47
|
+
rails g asana_exception_notifier:install
|
48
|
+
```
|
49
|
+
|
50
|
+
This command generates an initialize file (`config/initializers/asana_exception_notifier.rb`) where you can customize your configurations. ( Please see section **[2.2) Options for the Rack middleware](#available-options-for-the-rack-middleware)**\) for more information on available options )
|
51
|
+
|
52
|
+
Make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
|
53
|
+
|
54
|
+
AsanaExceptionNotifier is used as a rack middleware, or in the environment you want it to run. In most cases you would want AsanaExceptionNotifier to run on production. Thus, you can make it work by putting the following lines in your `config/environments/production.rb`:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack
|
58
|
+
```
|
59
|
+
|
60
|
+
### Rack/Sinatra
|
61
|
+
|
62
|
+
In order to use ExceptionNotification with Sinatra, please take a look in the [example application](https://github.com/bogdanRada/asana_exception_notifier/tree/master/examples/sinatra).
|
63
|
+
|
64
|
+
Background Notifications
|
65
|
+
------------------------
|
66
|
+
|
67
|
+
If you want to send notifications from a background process like DelayedJob, you should use the `notify_exception` method like this:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
begin
|
71
|
+
some code...
|
72
|
+
rescue => exception
|
73
|
+
ExceptionNotifier.notify_exception(exception, notifiers: :asana)
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
You can include information about the background process that created the error by including a data parameter:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
begin
|
81
|
+
some code...
|
82
|
+
rescue => exception
|
83
|
+
ExceptionNotifier.notify_exception(exception,
|
84
|
+
:data => {:worker => worker.to_s, :queue => queue, :payload => payload}, notifiers: :asana)
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
### Manually notify of exception
|
89
|
+
|
90
|
+
If your controller action manually handles an error, the notifier will never be run. To manually notify of an error you can do something like the following:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
rescue_from Exception, :with => :server_error
|
94
|
+
|
95
|
+
def server_error(exception)
|
96
|
+
# Whatever code that handles the exception
|
97
|
+
|
98
|
+
ExceptionNotifier.notify_exception(exception,
|
99
|
+
:env => request.env, :data => {:message => "was doing something wrong"}, notifiers: :asana)
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
Available Options for the Rack Middleware
|
104
|
+
-----------------------------------------
|
43
105
|
|
44
106
|
##### asana_api_key
|
45
107
|
|
@@ -133,66 +195,11 @@ More detailed, free-form textual information associated with the task. (Default:
|
|
133
195
|
|
134
196
|
This can be used to override the default template when rendering the exception details with customized template.
|
135
197
|
|
136
|
-
|
137
|
-
|
138
|
-
If you are settting up for the first time this gem, just run the following command from the terminal:
|
139
|
-
|
140
|
-
```
|
141
|
-
rails g asana_exception_notifier:install
|
142
|
-
```
|
143
|
-
|
144
|
-
This command generates an initialize file (`config/initializers/asana_exception_notifier.rb`) where you can customize your configurations.
|
145
|
-
|
146
|
-
Make sure the gem is not listed solely under the `production` group, since this initializer will be loaded regardless of environment.
|
147
|
-
|
148
|
-
AsanaExceptionNotifier is used as a rack middleware, or in the environment you want it to run. In most cases you would want AsanaExceptionNotifier to run on production. Thus, you can make it work by putting the following lines in your `config/environments/production.rb`:
|
149
|
-
|
150
|
-
```ruby
|
151
|
-
Rails.application.config.middleware.use ExceptionNotification::Rack
|
152
|
-
```
|
153
|
-
|
154
|
-
### Rack/Sinatra
|
155
|
-
|
156
|
-
In order to use ExceptionNotification with Sinatra, please take a look in the [example application](https://github.com/bogdanRada/asana_exception_notifier/tree/master/examples/sinatra).
|
198
|
+
##### unsafe_options
|
157
199
|
|
158
|
-
|
159
|
-
------------------------
|
160
|
-
|
161
|
-
If you want to send notifications from a background process like DelayedJob, you should use the `notify_exception` method like this:
|
162
|
-
|
163
|
-
```ruby
|
164
|
-
begin
|
165
|
-
some code...
|
166
|
-
rescue => exception
|
167
|
-
ExceptionNotifier.notify_exception(exception, notifiers: :asana)
|
168
|
-
end
|
169
|
-
```
|
170
|
-
|
171
|
-
You can include information about the background process that created the error by including a data parameter:
|
172
|
-
|
173
|
-
```ruby
|
174
|
-
begin
|
175
|
-
some code...
|
176
|
-
rescue => exception
|
177
|
-
ExceptionNotifier.notify_exception(exception,
|
178
|
-
:data => {:worker => worker.to_s, :queue => queue, :payload => payload}, notifiers: :asana)
|
179
|
-
end
|
180
|
-
```
|
181
|
-
|
182
|
-
### Manually notify of exception
|
183
|
-
|
184
|
-
If your controller action manually handles an error, the notifier will never be run. To manually notify of an error you can do something like the following:
|
185
|
-
|
186
|
-
```ruby
|
187
|
-
rescue_from Exception, :with => :server_error
|
188
|
-
|
189
|
-
def server_error(exception)
|
190
|
-
# Whatever code that handles the exception
|
200
|
+
*Array, optional*
|
191
201
|
|
192
|
-
|
193
|
-
:env => request.env, :data => {:message => "was doing something wrong"}, notifiers: :asana)
|
194
|
-
end
|
195
|
-
```
|
202
|
+
This can be used to specify options as strings that will be filtered from session and from request parameters ( The options will not be displayed in the HTML template)
|
196
203
|
|
197
204
|
Testing
|
198
205
|
-------
|
@@ -48,7 +48,7 @@ module AsanaExceptionNotifier
|
|
48
48
|
exception_service_data: exception_service,
|
49
49
|
request_data: setup_env_params,
|
50
50
|
parameters: @request.respond_to?(:filtered_parameters) ? filter_params(@request.filtered_parameters) : filter_params(request_params),
|
51
|
-
session: session.respond_to?(:to_hash) ? session.to_hash : session.to_h,
|
51
|
+
session: filter_params(session.respond_to?(:to_hash) ? session.to_hash : session.to_h),
|
52
52
|
cookies: @request.cookies.to_h
|
53
53
|
}.merge(@options).reject { |_key, value| value.blank? }
|
54
54
|
end
|