From 72b741d7c91a0dc17ab0d73ed43ae1ccf47f3313 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 5 Apr 2015 18:16:21 +0100 Subject: [PATCH] Added generateHttpResponse method to exception --- src/Exception/OAuthException.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Exception/OAuthException.php b/src/Exception/OAuthException.php index e8e5e723..653ee65b 100644 --- a/src/Exception/OAuthException.php +++ b/src/Exception/OAuthException.php @@ -127,4 +127,22 @@ class OAuthException extends \Exception // @codeCoverageIgnoreEnd return $headers; } + + /** + * Generate a HTTP response + * @return \Symfony\Component\HttpFoundation\Response + */ + public function generateHttpResponse() + { + return new Response( + json_encode( + [ + 'error' => $this->errorType, + 'message' => $this->getMessage() + ] + ), + $this->httpStatusCode, + $this->getHttpHeaders() + ); + } }