fix: conditions throwing errors break form state (#6113)

This commit is contained in:
Jarrod Flesch
2024-04-29 12:54:00 -04:00
committed by GitHub
parent b7a4d9cea4
commit 15db0a8018

View File

@@ -9,6 +9,7 @@ import type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.j
import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'
import { headersWithCors } from '../../utilities/headersWithCors.js'
import { routeError } from './routeError.js'
let cached = global._payload_fieldSchemaMap
@@ -226,14 +227,10 @@ export const buildFormState = async ({ req }: { req: PayloadRequestWithData }) =
status: httpStatus.OK,
})
} catch (err) {
return Response.json(
{
message: 'There was an error building form state',
},
{
headers,
status: httpStatus.BAD_REQUEST,
},
)
return routeError({
config: req.payload.config,
err,
req,
})
}
}