From 5965fc91c3c53e6421c425d1f935752d49abfd8d Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Fri, 8 Jun 2018 10:12:14 -0700 Subject: [PATCH] Improve error message for missing asset (#655) --- public/functions/asset.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/functions/asset.js b/public/functions/asset.js index 9d4fda337db95..4765e9b38e963 100644 --- a/public/functions/asset.js +++ b/public/functions/asset.js @@ -17,9 +17,11 @@ export const asset = () => ({ }, }, fn: (context, args) => { - // TODO: handle the case where the asset id provided doesn't exist const assetId = args._; - const { value } = getAssetById(getState(), assetId); - return value; + const asset = getAssetById(getState(), assetId); + if (asset !== undefined) { + return asset.value; + } + throw new Error('Could not get the asset by ID: ' + assetId); }, });