rack-insight 0.5.22 → 0.5.23

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,27 @@
1
1
  == HEAD
2
2
 
3
+ == 0.5.23 / 2012-09-14
4
+
5
+ * New Features
6
+
7
+ * No longer rescue Object, and instead rescue Standard Error.
8
+ If this is a problem strange non-StandardErrors should be wrapped. (pboling - Peter Boling)
9
+
10
+ * Refactor Panel error handling. (pboling - Peter Boling)
11
+
12
+ Create error handling method: `handle_error_for(method_name, exception)`
13
+ Logs the error.
14
+ Returns HTML for the view.
15
+ Simplifies error handling in any panel that overrides one of:
16
+ content, heading, content_for_request and heading_for_request
17
+ like this:
18
+
19
+ def content
20
+ # Do stuff
21
+ rescue StandardError => ex
22
+ handle_error_for(method_name, ex)
23
+ end
24
+
3
25
  == 0.5.22 / 2012-09-14
4
26
 
5
27
  * New Features
@@ -75,7 +75,7 @@ module Rack::Insight
75
75
  @db = SQLite3::Database.new(database_path)
76
76
  @db.execute("pragma foreign_keys = on")
77
77
  @db
78
- rescue Object => ex
78
+ rescue StandardError => ex
79
79
  msg = "Issue while loading SQLite DB:" + [ex.class, ex.message, ex.backtrace[0..4]].inspect
80
80
  logger.error{ msg }
81
81
 
@@ -244,13 +244,8 @@ module Rack::Insight
244
244
  heading
245
245
  end
246
246
  end
247
- rescue Object => ex
248
- nom = self.name rescue "xxx"
249
- msg = ["Failed to create heading_for_request for #{nom}","#{ex.class}: #{ex.message}"] + ex.backtrace
250
- logger.error(msg.join("\n"))
251
- "Err3: #{nom}
252
- <!-- Panel: #{self.inspect}\n
253
- #{msg.join("\n")} -->"
247
+ rescue StandardError => exception
248
+ handle_error_for('heading_for_request', exception)
254
249
  end
255
250
 
256
251
  def content_for_request(number)
@@ -270,34 +265,29 @@ module Rack::Insight
270
265
  else
271
266
  content
272
267
  end
273
- rescue Object => ex
274
- nom = self.name rescue "xxx"
275
- msg = ["Failed to create content_for_request for #{nom}","#{ex.class}: #{ex.message}"] + ex.backtrace
276
- logger.error(msg.join("\n"))
277
- "Err4: #{nom}
278
- <!-- Panel: #{self.inspect}\n
279
- #{msg.join("\n")} -->"
268
+ rescue StandardError => exception
269
+ handle_error_for('content_for_request', exception)
280
270
  end
281
271
 
282
272
  def heading
283
273
  self.camelized_name
284
- rescue Object => ex
285
- nom = self.name rescue "xxx"
286
- msg = ["Failed to create heading for #{nom}","#{ex.class}: #{ex.message}"] + ex.backtrace
287
- logger.error(msg.join("\n"))
288
- "Err1: #{nom}
289
- <!-- Panel: #{self.inspect}\n
290
- #{msg.join("\n")} -->"
274
+ rescue StandardError => exception
275
+ handle_error_for('heading', exception)
291
276
  end
292
277
 
293
278
  def content
294
279
  logger.info("Rack::Insight is using default content for #{self.class}") if verbose(:med)
295
280
  render_template 'no_content', :name => self.camelized_name
296
- rescue Object => ex
281
+ rescue StandardError => exception
282
+ handle_error_for('content', exception)
283
+ end
284
+
285
+ def handle_error_for(method_name, exception)
297
286
  nom = self.name rescue "xxx"
298
- msg = ["Failed to create content for #{nom}","#{ex.class}: #{ex.message}"] + ex.backtrace
287
+ msg = ["#{self.class}##{method_name} failed","#{exception.class}: #{exception.message}"] + exception.backtrace
299
288
  logger.error(msg.join("\n"))
300
- "Err2: #{nom}
289
+ # return HTML
290
+ "Error in #{nom}
301
291
  <!-- Panel: #{self.inspect}\n
302
292
  #{msg.join("\n")} -->"
303
293
  end
@@ -40,7 +40,7 @@ module Rack::Insight
40
40
 
41
41
  begin
42
42
  CompiledTemplates.module_eval(source, filename, 0)
43
- rescue Object => ex
43
+ rescue StandardError => ex
44
44
  logger.error do
45
45
  "#{ex.class.name}: #{ex.message} in\n" +
46
46
  source +
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module Insight
3
3
 
4
- VERSION = '0.5.22'
4
+ VERSION = '0.5.23'
5
5
 
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@
12
12
  <%= panel.heading_for_request(request_id) %>
13
13
  </a>
14
14
  <% end %>
15
- <% rescue Object => ex %>
15
+ <% rescue StandardError => ex %>
16
16
  Err5: <%= panel.name rescue "xxx" %>
17
17
  <!-- Panel: <%= panel.inspect %> -->
18
18
  <!-- <%= ([ex.class.name, ex.message] + ex.backtrace).join("\n") %> -->
@@ -16,8 +16,8 @@
16
16
  </div>
17
17
  <% begin %>
18
18
  <%= panel.content_for_request(request_id) %>
19
- <% rescue Object => ex %>
20
- <%= "Error #{ex.class.name}: #{ex.message} <!-- #{ex.backtrace[0..5]} -->" %>
19
+ <% rescue StandardError => ex %>
20
+ <%= "Error #{ex.class.name}: #{ex.message} <!-- #{ex.backtrace.join("\n")} -->" %>
21
21
  <% end %>
22
22
  </div>
23
23
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-insight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: