From 3d6a29795b9a65f768fb066fdbc62633f33554fa Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 22 Aug 2019 12:26:46 -0400 Subject: [PATCH] Carry headers through the handler --- app/Exceptions/Converters/GenericException.php | 4 +--- app/Exceptions/HttpException.php | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Exceptions/Converters/GenericException.php b/app/Exceptions/Converters/GenericException.php index 9f028102..d396a05c 100644 --- a/app/Exceptions/Converters/GenericException.php +++ b/app/Exceptions/Converters/GenericException.php @@ -40,9 +40,7 @@ class GenericException extends HttpException public function getErrorMetadata(): array { $metadata = []; - $metadata['error'] = [ - 'original_exception' => get_class($this->exception), - ]; + $metadata['original_exception'] = get_class($this->exception); // Only add trace if in dev if (config('app.env') === 'dev') { diff --git a/app/Exceptions/HttpException.php b/app/Exceptions/HttpException.php index ed381bfe..2c223d0a 100644 --- a/app/Exceptions/HttpException.php +++ b/app/Exceptions/HttpException.php @@ -49,13 +49,15 @@ abstract class HttpException extends SymfonyHttpException */ public function getResponse() { + $headers = []; + $headers['content-type'] = 'application/problem+json'; + $headers = array_merge($headers, $this->getHeaders()); + return response() ->json( $this->getJson(), $this->getStatusCode(), - [ - 'content-type' => 'application/problem+json', - ] + $headers ); } }