Skip to content

Commit

Permalink
Better error messaging for promise sources
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Oct 23, 2024
1 parent ef9c3fb commit bf70fa0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/AssetCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class AssetCache {
(typeof url === "object" && typeof url.then === "function") ||
(typeof url === "function" && url.constructor.name === "AsyncFunction")
) {
if(typeof options.formatUrlForDisplay !== "function") {
throw new Error("When caching an arbitrary promise source, options.formatUrlForDisplay is required.");
}

uniqueKey = options.formatUrlForDisplay();
} else {
uniqueKey = url;
Expand Down

0 comments on commit bf70fa0

Please sign in to comment.