Module: Diffend::HandleErrors::Report
- Defined in:
- lib/diffend/handle_errors/report.rb
Overview
Module responsible for reporting errors to diffend
Class Method Summary collapse
- .build_request_object(config, payload) ⇒ Diffend::RequestObject
-
.call(config:, message:, exception: nil, payload: {}, report: false, raise_exception: true) ⇒ Net::HTTPResponse
Execute request to Diffend.
-
.errors_url(project_id) ⇒ String
Provides diffend errors endpoint url.
-
.prepare_exception_payload(exception, payload) ⇒ Hash
Prepare exception payload and display it to stdout.
Class Method Details
.build_request_object(config, payload) ⇒ Diffend::RequestObject
37 38 39 40 41 42 43 44 |
# File 'lib/diffend/handle_errors/report.rb', line 37 def build_request_object(config, payload) Diffend::RequestObject.new( config: config, url: errors_url(config.project_id), payload: payload, request_method: :post ) end |
.call(config:, message:, exception: nil, payload: {}, report: false, raise_exception: true) ⇒ Net::HTTPResponse
Execute request to Diffend
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/diffend/handle_errors/report.rb', line 18 def call(config:, message:, exception: nil, payload: {}, report: false, raise_exception: true) exception_payload = prepare_exception_payload(exception, payload) Bundler.ui.error(Diffend::HandleErrors::Messages::PAYLOAD_DUMP) Bundler.ui.error(Diffend::HandleErrors::Messages.const_get(.to_s.upcase)) if report Diffend::Request.call( build_request_object(config, exception_payload) ) end raise Diffend::Errors::HandledException if raise_exception end |
.errors_url(project_id) ⇒ String
Provides diffend errors endpoint url
63 64 65 66 67 |
# File 'lib/diffend/handle_errors/report.rb', line 63 def errors_url(project_id) return ENV['DIFFEND_ERROR_URL'] if ENV.key?('DIFFEND_ERROR_URL') "https://my.diffend.io/api/projects/#{project_id}/errors" end |
.prepare_exception_payload(exception, payload) ⇒ Hash
Prepare exception payload and display it to stdout
52 53 54 55 56 |
# File 'lib/diffend/handle_errors/report.rb', line 52 def prepare_exception_payload(exception, payload) Diffend::HandleErrors::BuildExceptionPayload .call(exception, payload) .tap(&Diffend::HandleErrors::DisplayToStdout.method(:call)) end |