Skip to content

Commit

Permalink
feat!: in case of an exception with empty error bag return {} inste…
Browse files Browse the repository at this point in the history
…ad of []
  • Loading branch information
Mohammad-Alavi committed Apr 27, 2022
1 parent c480185 commit 1a3c7bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Abstracts/Exceptions/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [];

Expand All @@ -90,6 +91,6 @@ public function getErrors(): array
$translatedErrors[$key] = $translatedValues;
}

return $translatedErrors;
return empty($translatedErrors) ? new stdClass(): $translatedErrors;
}
}

0 comments on commit 1a3c7bf

Please sign in to comment.