Skip to content

Commit

Permalink
Improve error message for missing asset (elastic#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan authored Jun 8, 2018
1 parent 0398a3a commit 5965fc9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/functions/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});

0 comments on commit 5965fc9

Please sign in to comment.