fix: conditions throwing errors break form state (#6113)
This commit is contained in:
@@ -9,6 +9,7 @@ import type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.j
|
|||||||
|
|
||||||
import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'
|
import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'
|
||||||
import { headersWithCors } from '../../utilities/headersWithCors.js'
|
import { headersWithCors } from '../../utilities/headersWithCors.js'
|
||||||
|
import { routeError } from './routeError.js'
|
||||||
|
|
||||||
let cached = global._payload_fieldSchemaMap
|
let cached = global._payload_fieldSchemaMap
|
||||||
|
|
||||||
@@ -226,14 +227,10 @@ export const buildFormState = async ({ req }: { req: PayloadRequestWithData }) =
|
|||||||
status: httpStatus.OK,
|
status: httpStatus.OK,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return Response.json(
|
return routeError({
|
||||||
{
|
config: req.payload.config,
|
||||||
message: 'There was an error building form state',
|
err,
|
||||||
},
|
req,
|
||||||
{
|
})
|
||||||
headers,
|
|
||||||
status: httpStatus.BAD_REQUEST,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user