Method: Honeybadger::Agent#notify
- Defined in:
- lib/honeybadger/agent.rb
permalink #notify(exception_or_opts = nil, opts = {}, **kwargs) ⇒ String, false
Sends an exception to Honeybadger. Does not report ignored exceptions by default.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/honeybadger/agent.rb', line 127 def notify(exception_or_opts = nil, opts = {}, **kwargs) if !config[:'exceptions.enabled'] debug { 'disabled feature=notices' } return false end 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) elsif !exception_or_opts.nil? opts[:error_message] = exception_or_opts.to_s end validate_notify_opts!(opts) ( "Honeybadger Notice", metadata: opts, category: "notice" ) if config[:'breadcrumbs.enabled'] opts[:rack_env] ||= context_manager.get_rack_env opts[:global_context] ||= context_manager.get_context opts[:breadcrumbs] ||= .dup opts[:request_id] ||= context_manager.get_request_id notice = Notice.new(config, opts) config.before_notify_hooks.each do |hook| break if notice.halted? with_error_handling { hook.call(notice) } end unless notice.api_key =~ NOT_BLANK error { sprintf('Unable to send error report: API key is missing. id=%s', notice.id) } return false end if !opts[:force] && notice.ignore? debug { sprintf('ignore notice feature=notices id=%s', notice.id) } return false end if notice.halted? debug { 'halted notice feature=notices' } return false end info { sprintf('Reporting error id=%s', notice.id) } if opts[:sync] || config[:sync] send_now(notice) else push(notice) end if exception_or_opts.is_a?(Exception) exception_or_opts.instance_variable_set(:@__hb_notice_id, notice.id) unless exception_or_opts.frozen? end notice.id end |