-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUBY-991 handle Exceptions with non-String messages
- Loading branch information
Showing
2 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper')) | ||
|
||
class NewRelic::Agent::NoticedErrorTest < Test::Unit::TestCase | ||
def setup | ||
@path = 'foo/bar/baz' | ||
@params = { 'key' => 'val' } | ||
@time = Time.now | ||
end | ||
|
||
def test_to_collector_array | ||
time = Time.now | ||
error = NewRelic::NoticedError.new('path', {'key' => 'val'}, | ||
Exception.new('test exception'), time) | ||
e = Exception.new('test exception') | ||
error = NewRelic::NoticedError.new(@path, @params, e, @time) | ||
expected = [ | ||
(time.to_f * 1000).round, 'path', 'test exception', 'Exception', | ||
{'key' => 'val'} | ||
(@time.to_f * 1000).round, @path, 'test exception', 'Exception', @params | ||
] | ||
assert_equal expected, error.to_collector_array | ||
end | ||
|
||
def test_handles_non_string_exception_messages | ||
e = Exception.new({ :non => :string }) | ||
error = NewRelic::NoticedError.new(@path, @params, e, @time) | ||
assert_equal(String, error.message.class) | ||
end | ||
end |