| 1 | package ForgeOps::Tracker::Reporter; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # Ties Configuration, EventBuilder, and DeliveryQueue together into the one thing callers actually | ||||||||||
| 7 | # need: report an exception. Mirrors gems/forge_ops_tracker's ErrorSubscriber#report: never | ||||||||||
| 8 | # throws. An error reporter that itself throws while reporting an error is the worst possible | ||||||||||
| 9 | # failure mode, so every path here is wrapped to guarantee this never propagates back into the | ||||||||||
| 10 | # host app. | ||||||||||
| 11 | 6 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 12 | 6 | my ($class, $configuration, $event_builder, $delivery_queue) = @_; | |||||||||
| 13 | 6 | return bless { | |||||||||
| 14 | configuration => $configuration, | ||||||||||
| 15 | event_builder => $event_builder, | ||||||||||
| 16 | delivery_queue => $delivery_queue, | ||||||||||
| 17 | }, $class; | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 6 | ▶ | sub report { | ||||||||
|
Subroutine
report: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 21 | 6 | my ($self, $error, $context, $user, $breadcrumbs, $request) = @_; | |||||||||
| 22 | |||||||||||
| 23 | eval { | ||||||||||
| 24 | 6 | ▶ | return unless $self->{configuration}->is_enabled; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 5 | my $payload = $self->{event_builder}->build($error, $context, $user, $breadcrumbs, $request); | |||||||||
| 27 | 4 | $self->{delivery_queue}->push($payload); | |||||||||
| 28 | 3 | 1; | |||||||||
| 29 | 6 | ▶ | } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 3 | my $err = $@; | |||||||||
| 31 | 3 | eval { $self->{configuration}->log("[forge-ops-tracker] report failed: $err") }; | |||||||||
| 32 | }; | ||||||||||
| 33 | |||||||||||
| 34 | 6 | return; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 1 | 1; | |||||||||