wrangler 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -247,3 +247,19 @@ To build:
247
247
  cd .../wrangler
248
248
  rake gemspec
249
249
  rake build
250
+
251
+ To test:
252
+ Now at least, wrangler testing is all manual, which is bad (see TODO). So to
253
+ test, try at least some of the following cases:
254
+ * enable/disable local exception handling
255
+ * enable/disable local notification
256
+ * enable/disable delayed_job notification
257
+ * raise an exception with a status_code
258
+ * raise an exception without a status_code
259
+ * raise an exception explicitly set to result in notification
260
+ * raise an exception with ancestor class set to result in notification
261
+ * raise an exception with error status code set to result in notification
262
+ * raise an exception with explicit class mapping to error page
263
+ * raise an exception with ancestor class mapping to error page
264
+ * raise an exception with status_code mapping to error page
265
+ * raise an ADDITIONAL exception inside the exception handling code...
@@ -203,27 +203,30 @@ module Wrangler
203
203
  status_code = Wrangler::ExceptionHandler.status_code_for_exception(exception)
204
204
  request_data = request_data_from_request(request) unless request.nil?
205
205
 
206
+ log_exception(exception, request_data, status_code)
207
+
206
208
  if notify_on_exception?(exception, status_code)
207
209
  if notify_with_delayed_job?
208
210
  # don't pass in request as it contains not-easily-serializable stuff
211
+ log_error
209
212
  Wrangler::ExceptionNotifier.send_later(:deliver_exception_notification,
210
213
  exception,
214
+ exception.to_str,
211
215
  proc_name,
212
216
  exception.backtrace,
213
217
  status_code,
214
218
  request_data)
215
219
  else
216
220
  Wrangler::ExceptionNotifier.deliver_exception_notification(exception,
217
- proc_name,
218
- exception.backtrace,
219
- status_code,
220
- request_data,
221
- request)
221
+ exception.to_str,
222
+ proc_name,
223
+ exception.backtrace,
224
+ status_code,
225
+ request_data,
226
+ request)
222
227
  end
223
228
  end
224
229
 
225
- log_exception(exception, request_data, status_code)
226
-
227
230
  if render_errors
228
231
  render_error_template(exception, status_code)
229
232
  end
@@ -68,7 +68,10 @@ module Wrangler
68
68
  # be nil and MUST be nil if calling this method with
69
69
  # delayed_job. Optional.
70
70
  #---------------------------------------------------------------------------
71
- def exception_notification(exception, proc_name, backtrace,
71
+ def exception_notification(exception,
72
+ exception_message,
73
+ proc_name,
74
+ backtrace,
72
75
  status_code = nil,
73
76
  request_data = nil,
74
77
  request = nil)
@@ -90,6 +93,7 @@ module Wrangler
90
93
 
91
94
  body_hash =
92
95
  { :exception => exception,
96
+ :exception_message => exception_message,
93
97
  :backtrace => backtrace,
94
98
  :status_code => status_code,
95
99
  :request_data => request_data,
@@ -102,7 +106,7 @@ module Wrangler
102
106
  subject "[#{proc_name + (proc_name ? ' ' : '')}" +
103
107
  "#{config[:subject_prefix]}] " +
104
108
  "#{exception.class.name}: " +
105
- "#{exception.message.inspect}"
109
+ "#{exception_message}"
106
110
  body body_hash
107
111
  sent_on Time.now
108
112
  content_type 'text/plain'
@@ -11,7 +11,8 @@ module Wrangler
11
11
  # http://ruby-doc.org/core/classes/Module.html#M001642
12
12
  module_function
13
13
 
14
- # utility to determine if a class has another class as its ancestor.
14
+
15
+ # utility to determine if a class has another class as its ancestor.
15
16
  #
16
17
  # returns the ancestor class (if any) that is found to be the ancestor
17
18
  # of klass (will return the nearest ancestor in other_klasses).
@@ -54,14 +55,15 @@ module Wrangler
54
55
  return nil
55
56
  end
56
57
 
58
+
57
59
  # log the exception using logger if available. if object does not have a
58
60
  # logger, will just puts()
59
61
  #-----------------------------------------------------------------------------
60
62
  def log_exception(exception, request_data = nil, status_code = nil)
61
63
  msgs = []
62
-
63
64
  msgs << "An exception was caught (#{exception.class.name}):"
64
- msgs << exception.message
65
+ msgs << exception.to_str
66
+
65
67
  unless request_data.blank?
66
68
  msgs << "Request params were:"
67
69
  msgs << request_data.inspect
@@ -76,6 +78,7 @@ module Wrangler
76
78
  log_error msgs
77
79
  end
78
80
 
81
+
79
82
  # handles logging error messages, using logger if available and puts otherwise
80
83
  #-----------------------------------------------------------------------------
81
84
  def log_error(msgs)
@@ -92,6 +95,7 @@ module Wrangler
92
95
  end
93
96
  end
94
97
 
98
+
95
99
  # shorthand access to the exception handling config
96
100
  #-----------------------------------------------------------------------------
97
101
  def config
@@ -1,4 +1,4 @@
1
- <%#
1
+ <%
2
2
  # NOTE: be very careful pulling data out of request in the view...it is
3
3
  # NOT cleaned, and may contain private data (e.g. passwords), so
4
4
  # scrutinize any use of @request in the views!
@@ -9,7 +9,7 @@
9
9
  <% end -%>
10
10
 
11
11
  A <%= @exception.class %> occurred:
12
- * <%= @exception.inspect %>
12
+ * <%= @exception_message %>
13
13
  in <%= @backtrace.first %>
14
14
 
15
15
  <% unless @backtrace.blank? -%>
data/wrangler.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wrangler}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Percival"]
12
- s.date = %q{2009-11-19}
12
+ s.date = %q{2009-11-30}
13
13
  s.description = %q{A gem for handling exceptions thrown inside your Rails app. If you include the
14
14
  gem in your application controller, wrangler will render the error pages you
15
15
  configure for each exception or HTTP error code. It will also handle notifying
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Percival
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-19 00:00:00 -08:00
12
+ date: 2009-11-30 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency