Skip to content

Return null on asset cache miss instead of throwing#441

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/update-cache-get-function
Draft

Return null on asset cache miss instead of throwing#441
Copilot wants to merge 2 commits intodevfrom
copilot/update-cache-get-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

AssetCache.get() previously threw on a cache miss, forcing callers to either pre-load assets or catch errors. It now returns null | T, aligning with standard cache lookup semantics.

Changes

  • AssetCache interfaceget return type changed from T to T | null
  • ImageCache.get() — returns null on miss instead of throwing
  • ImageCache.getOrLoad() — guards against the (theoretically unreachable) null after load() to satisfy the type system
  • image-cache.test.ts — updated cache-miss test to assert null instead of a thrown error

Before / After

// Before
imageCache.get('missing.png'); // throws Error

// After
imageCache.get('missing.png'); // returns null

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: stormmuller <17644200+stormmuller@users.noreply.github.com>
Copilot AI changed the title [WIP] Update asset caches to return null on cache miss Return null on asset cache miss instead of throwing Mar 18, 2026
Copilot AI requested a review from stormmuller March 18, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants