Permalink
Browse files

prefer provided error message over original exception message

closes #111
  • Loading branch information...
1 parent 2ba25e8 commit 8fdefb80e097e1b3306eac1869a95183396f4d21 @shime shime committed Aug 22, 2012
Showing with 19 additions and 11 deletions.
  1. +1 −1 lib/airbrake/notice.rb
  2. +12 −10 test/helper.rb
  3. +6 −0 test/notice_test.rb
View
@@ -113,7 +113,7 @@ def initialize(args)
self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters)
self.error_class = exception_attribute(:error_class) {|exception| exception.class.name }
self.error_message = exception_attribute(:error_message, 'Notification') do |exception|
- "#{exception.class.name}: #{exception.message}"
+ "#{exception.class.name}: #{args[:error_message] || exception.message}"
end
self.hostname = local_hostname
View
@@ -132,16 +132,6 @@ def build_exception(opts = {})
BacktracedException.new(opts)
end
- class BacktracedException < Exception
- attr_accessor :backtrace
- def initialize(opts)
- @backtrace = opts[:backtrace]
- end
- def set_backtrace(bt)
- @backtrace = bt
- end
- end
-
def build_notice_data(exception = nil)
exception ||= build_exception
{
@@ -259,3 +249,15 @@ def error(*args); end
def fatal(*args); end
end
+class BacktracedException < Exception
+ attr_accessor :backtrace
+ def initialize(opts)
+ @backtrace = opts[:backtrace]
+ end
+ def set_backtrace(bt)
+ @backtrace = bt
+ end
+ def message
+ "Something went wrong. Did you press the red button?"
+ end
+end
View
@@ -481,4 +481,10 @@ def user
assert_equal session_data, notice.session_data
end
+
+ should "prefer passed error_message to exception message" do
+ exception = build_exception
+ notice = build_notice(:exception => exception,:error_message => "Random ponies")
+ assert_equal "BacktracedException: Random ponies", notice.error_message
kylev
kylev Aug 23, 2012

Hooray for ponies and improved functionality!

shime
shime Aug 23, 2012 Contributor

😆

@kylev thanks for reporting this!

+ end
end

0 comments on commit 8fdefb8

Please sign in to comment.