Skip to content
This repository has been archived by the owner on Jun 23, 2021. It is now read-only.

Commit

Permalink
III-3528 Pass closure to error method to avoid early initialisation a…
Browse files Browse the repository at this point in the history
…nd empty jwt
  • Loading branch information
LucWollants committed Oct 9, 2020
1 parent e44c5a1 commit 7783096
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/ApiErrorHandler.php
Expand Up @@ -18,7 +18,7 @@ public function __construct(SentryErrorHandler $uncaughtErrorHandler)
$this->uncaughtErrorHandler = $uncaughtErrorHandler;
}

public function __invoke(Exception $exception): ApiProblemJsonResponse
public function handle(Exception $exception): ApiProblemJsonResponse
{
$this->uncaughtErrorHandler->handle($exception);

Expand Down
15 changes: 8 additions & 7 deletions app/ErrorHandlerProvider.php
Expand Up @@ -2,6 +2,7 @@

namespace CultuurNet\UDB3\UiTPASService;

use Exception;
use Sentry\State\HubInterface;
use Silex\Application;
use Silex\ServiceProviderInterface;
Expand All @@ -12,16 +13,16 @@ public function register(Application $app): void
{
$app[SentryErrorHandler::class] = $app->share(
function ($app) {
return new SentryErrorHandler($app[HubInterface::class]);
return new SentryErrorHandler(
$app[HubInterface::class],
$app['jwt'] ?? null
);
}
);

$app[ApiErrorHandler::class] = $app->share(
function () use ($app) {
return new ApiErrorHandler($app[SentryErrorHandler::class]);
}
);
$app->error($app[ApiErrorHandler::class]);
$app->error(function (Exception $e) use ($app) {
return (new ApiErrorHandler($app[SentryErrorHandler::class]))->handle($e);
});
}

public function boot(Application $app): void
Expand Down

0 comments on commit 7783096

Please sign in to comment.