diff --git a/Abstracts/Exceptions/Exception.php b/Abstracts/Exceptions/Exception.php index a7567573b..9900aec3f 100644 --- a/Abstracts/Exceptions/Exception.php +++ b/Abstracts/Exceptions/Exception.php @@ -5,6 +5,7 @@ use Exception as BaseException; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Log; +use stdClass; use Throwable; abstract class Exception extends BaseException @@ -70,7 +71,7 @@ public function withErrors(array $errors, bool $override = true): Exception return $this; } - public function getErrors(): array + public function getErrors(): array|stdClass { $translatedErrors = []; @@ -90,6 +91,6 @@ public function getErrors(): array $translatedErrors[$key] = $translatedValues; } - return $translatedErrors; + return empty($translatedErrors) ? new stdClass(): $translatedErrors; } }