Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prefer provided error message over original exception message

closes #111
  • Loading branch information...
commit 8fdefb80e097e1b3306eac1869a95183396f4d21 1 parent 2ba25e8
@shime shime authored
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
2  lib/airbrake/notice.rb
@@ -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
22 test/helper.rb
@@ -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
6 test/notice_test.rb
@@ -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 added a note

Hooray for ponies and improved functionality!

@shime
shime added a note

:laughing:

@kylev thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.