Better handle null imageUrl in /api/outfitImage
Oops, right, this is a nullable field! Before this change, a null here would crash the function. Now, it returns a helpful error message!
This commit is contained in:
parent
b8081d98aa
commit
8f845e7264
1 changed files with 9 additions and 0 deletions
|
@ -157,12 +157,14 @@ const GRAPHQL_QUERY = gql`
|
|||
outfit(id: $outfitId) {
|
||||
petAppearance {
|
||||
layers {
|
||||
id
|
||||
imageUrl(size: $size)
|
||||
}
|
||||
...PetAppearanceForGetVisibleLayers
|
||||
}
|
||||
itemAppearances {
|
||||
layers {
|
||||
id
|
||||
imageUrl(size: $size)
|
||||
}
|
||||
...ItemAppearanceForGetVisibleLayers
|
||||
|
@ -198,6 +200,13 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
|||
|
||||
const { petAppearance, itemAppearances } = data.outfit;
|
||||
const visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
||||
|
||||
for (const layer of visibleLayers) {
|
||||
if (!layer.imageUrl) {
|
||||
throw new Error(`layer ${layer.id} has no imageUrl for size ${size}`);
|
||||
}
|
||||
}
|
||||
|
||||
return visibleLayers
|
||||
.sort((a, b) => a.depth - b.depth)
|
||||
.map((layer) => layer.imageUrl);
|
||||
|
|
Loading…
Reference in a new issue