Fix various API 500 errors.

This commit is contained in:
James Cole
2025-01-26 06:30:38 +01:00
parent 6d89485792
commit c204533195
6 changed files with 39 additions and 20 deletions

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Brick\Math\Exception\NumberFormatException;
use FireflyIII\Jobs\MailError;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
@@ -133,10 +134,10 @@ class Handler extends ExceptionHandler
return response()->json(['message' => $e->getMessage(), 'exception' => 'BadHttpHeaderException'], $e->statusCode);
}
if($e instanceof ValidationException && $expectsJson) {
if(($e instanceof ValidationException || $e instanceof NumberFormatException) && $expectsJson) {
$errorCode = 422;
return response()->json(
['message' => sprintf('Validation exception: %s', $e->getMessage()), 'errors' => ['date' => 'Date is invalid']],
['message' => sprintf('Validation exception: %s', $e->getMessage()), 'errors' => ['field' => 'Field is invalid']],
$errorCode
);
}