feat(JsonResponse): output errorMessages

master
dufraissejeremy 2 years ago
parent 49ad30f7da
commit 78902e0502
  1. 4
      src/JsonResponse.php

@ -65,7 +65,6 @@ class JsonResponse implements JsonSerializable
'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, DELETE, PUT, PATCH', 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, DELETE, PUT, PATCH',
'Access-Control-Max-Age' => '86400' 'Access-Control-Max-Age' => '86400'
], $headers); ], $headers);
$this->preparedOutput = '';
} }
/** /**
@ -161,6 +160,9 @@ class JsonResponse implements JsonSerializable
protected function preparedOutput(): JsonResponse protected function preparedOutput(): JsonResponse
{ {
try { try {
if (!empty($GLOBALS['errorMessages'])){
$this->mergeInContent(['errorMessages'=>$GLOBALS['errorMessages']]);
}
json_encode($this->content); json_encode($this->content);
} catch (Throwable $th) { } catch (Throwable $th) {
$this->code = 500; $this->code = 500;

Loading…
Cancel
Save