Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/OpenConext/EngineBlockBridge/ErrorReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OpenConext\EngineBlock\Service\FeedbackStateHelperInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Throwable;

class ErrorReporter
{
Expand Down Expand Up @@ -66,6 +67,10 @@ public function reportError(Exception $exception, string $messageSuffix): void

try {
$this->storeSessionFeedback($exception);
} catch (Throwable $sessionException) {
$this->logger->warning(
'Unable to store feedback info in session: ' . $sessionException->getMessage(),
);
} finally {
// flush all messages in queue, something went wrong!
$this->engineBlockApplicationSingleton->flushLog('An error was caught');
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/OpenConext/EngineBlockBridge/ErrorReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,16 @@ public function it_stores_the_pep_policy_decision_in_the_session(): void

self::assertSame($decision, $this->session->get('error_authorization_policy_decision'));
}

#[Test]
public function it_does_not_propagate_exceptions_thrown_while_storing_feedback_in_the_session(): void
{
$this->feedbackInfoCollector
->shouldReceive('collect')
->andThrow(new Exception('Failed to start the session because headers have already been sent'));

$this->applicationSingleton->shouldReceive('flushLog')->with('An error was caught')->once();

$this->reporter->reportError(new Exception('test'), '');
}
}