From 22e6a350dd266cd0d266b92dcc380788b44a1c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Guti=C3=A9rrez?= Date: Wed, 11 May 2016 14:13:58 +0200 Subject: [PATCH] unify middleware exception responses --- src/Middleware/AuthorizationServerMiddleware.php | 5 ++--- src/Middleware/ResourceServerMiddleware.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Middleware/AuthorizationServerMiddleware.php b/src/Middleware/AuthorizationServerMiddleware.php index d33cbd31..6c2d08b2 100644 --- a/src/Middleware/AuthorizationServerMiddleware.php +++ b/src/Middleware/AuthorizationServerMiddleware.php @@ -46,9 +46,8 @@ class AuthorizationServerMiddleware return $exception->generateHttpResponse($response); // @codeCoverageIgnoreStart } catch (\Exception $exception) { - $response->getBody()->write($exception->getMessage()); - - return $response->withStatus(500); + return (new OAuthServerException($exception->getMessage(), 0, 'unknown_error', 500)) + ->generateHttpResponse($response); // @codeCoverageIgnoreEnd } diff --git a/src/Middleware/ResourceServerMiddleware.php b/src/Middleware/ResourceServerMiddleware.php index 6d67cb68..9e235c35 100644 --- a/src/Middleware/ResourceServerMiddleware.php +++ b/src/Middleware/ResourceServerMiddleware.php @@ -46,9 +46,8 @@ class ResourceServerMiddleware return $exception->generateHttpResponse($response); // @codeCoverageIgnoreStart } catch (\Exception $exception) { - $response->getBody()->write($exception->getMessage()); - - return $response->withStatus(500); + return (new OAuthServerException($exception->getMessage(), 0, 'unknown_error', 500)) + ->generateHttpResponse($response); // @codeCoverageIgnoreEnd }