Updated exception reference

This commit is contained in:
Alex Bilbie 2015-11-16 09:27:49 +00:00
parent 32b451aa21
commit c0bdd22154

View File

@ -1,6 +1,6 @@
<?php <?php
use League\OAuth2\Server\Exception\OAuthException; use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\ClientCredentialsGrant; use League\OAuth2\Server\Grant\ClientCredentialsGrant;
use League\OAuth2\Server\Server; use League\OAuth2\Server\Server;
@ -27,14 +27,13 @@ $server->enableGrantType(new ClientCredentialsGrant($clientRepository, $scopeRep
// App // App
$app = new App([Server::class => $server]); $app = new App([Server::class => $server]);
unset($app->getContainer()['errorHandler']);
$app->post('/access_token', function (Request $request, Response $response) { $app->post('/access_token', function (Request $request, Response $response) {
/** @var Server $server */ /** @var Server $server */
$server = $this->getContainer()->get(Server::class); $server = $this->getContainer()->get(Server::class);
try { try {
return $server->respondToRequest($request); return $server->respondToRequest($request);
} catch (OAuthException $e) { } catch (OAuthServerException $e) {
return $e->generateHttpResponse(); return $e->generateHttpResponse();
} catch (\Exception $e) { } catch (\Exception $e) {
return $response->withStatus(500)->write($e->getMessage()); return $response->withStatus(500)->write($e->getMessage());