Proper error handling for missing original

This commit is contained in:
Zoe Roux 2025-03-08 16:27:00 +01:00
parent cca0da4bf6
commit fd57f506c1
No known key found for this signature in database
2 changed files with 14 additions and 2 deletions

View File

@ -48,6 +48,13 @@ export const seedMovie = async (
const { translations, videos, collection, studios, ...movie } = seed;
const nextRefresh = guessNextRefresh(movie.airDate ?? new Date());
const original = translations[movie.originalLanguage];
if (!original) {
return {
status: 422,
message: "No translation available in the original language.",
};
}
const col = await insertCollection(collection, {
kind: "movie",
@ -55,7 +62,6 @@ export const seedMovie = async (
...seed,
});
const original = translations[movie.originalLanguage];
const show = await insertShow(
{
kind: "movie",

View File

@ -83,6 +83,13 @@ export const seedSerie = async (
...serie
} = seed;
const nextRefresh = guessNextRefresh(serie.startAir ?? new Date());
const original = translations[serie.originalLanguage];
if (!original) {
return {
status: 422,
message: "No translation available in the original language.",
};
}
const col = await insertCollection(collection, {
kind: "serie",
@ -90,7 +97,6 @@ export const seedSerie = async (
...seed,
});
const original = translations[serie.originalLanguage];
const show = await insertShow(
{
kind: "serie",