lib/honeybadger/agent.rb in honeybadger-5.2.1 vs lib/honeybadger/agent.rb in honeybadger-5.3.0

- old
+ new

@@ -89,19 +89,20 @@ # my_data: 'value' # }) # => '-1dfb92ae-9b01-42e9-9c13-31205b70744a' # end # # # Custom notification: - # Honeybadger.notify('Something went wrong.', { + # Honeybadger.notify('Something went wrong.', # error_class: 'MyClass', # context: {my_data: 'value'} - # }) # => '06220c5a-b471-41e5-baeb-de247da45a56' + # ) # => '06220c5a-b471-41e5-baeb-de247da45a56' # # @param [Exception, Hash, Object] exception_or_opts An Exception object, # or a Hash of options which is used to build the notice. All other types # of objects will be converted to a String and used as the :error_message. # @param [Hash] opts The options Hash when the first argument is an Exception. + # @param [Hash] kwargs options as keyword args. # # @option opts [String] :error_message The error message. # @option opts [String] :error_class ('Notice') The class name of the error. # @option opts [Array] :backtrace The backtrace of the error (optional). # @option opts [String] :fingerprint The grouping fingerprint of the exception (optional). @@ -116,20 +117,20 @@ # @option opts [String] :url The HTTP request URL (optional). # @option opts [Exception] :cause The cause for this error (optional). # # @return [String] UUID reference to the notice within Honeybadger. # @return [false] when ignored. - def notify(exception_or_opts, opts = {}) + def notify(exception_or_opts = nil, opts = {}, **kwargs) opts = opts.dup + opts.merge!(kwargs) if exception_or_opts.is_a?(Exception) already_reported_notice_id = exception_or_opts.instance_variable_get(:@__hb_notice_id) return already_reported_notice_id if already_reported_notice_id - opts[:exception] = exception_or_opts elsif exception_or_opts.respond_to?(:to_hash) opts.merge!(exception_or_opts.to_hash) - else + elsif !exception_or_opts.nil? opts[:error_message] = exception_or_opts.to_s end validate_notify_opts!(opts)