Skip to content

ContentManager.Load: better message when asset is not found (and throw exception in all cases) - #3327

Merged
xen2 merged 2 commits into
stride3d:masterfrom
xen2:feature/asset-not-found
Aug 5, 2026
Merged

xen2 merged 2 commits into
stride3d:masterfrom
xen2:feature/asset-not-found

Conversation

@xen2

@xen2 xen2 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

PR Details

As discussed on Discord, I tried to make a better error message when an asset is not found.

Case 1: root-differing candidates ("did you mean"):

The asset 'StrideDefaultFont' could not be found. Did you mean:
  '/MyLib/StrideDefaultFont'
  '/Stride.Engine/StrideDefaultFont'

Case 2: same name in other folders (capped at 5):

The asset 'WrongFolder/Ground' could not be found. Assets with the same name exist at:
  '/A/Ground'
  '/B/Ground'
  '/C/Ground'
  '/D/Sub/Ground'
  '/E/Ground'
  (and 2 more)

I also made it a proper exception (previous code was a bit weird: log error and caught exception if debugger attached)
It didn't feel right that ContentManager.Load could return null with a simple log error (it was highly unlikely user was checking for null).
We could later add a ContentManager.TryLoad if really necessary, but ContentManager.Exists should be enough for now.

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation (done in XML doc, need a comment in release notes)
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@xen2 xen2 changed the title Feature/asset not found ContentManager.Load: better message when asset is not found (and throw exception in all cases) Aug 5, 2026
@xen2 xen2 added ci-enduser Run the end-user sample screenshot + packaging suite on this PR ci-editor Run the GameStudio editor screenshot suite on this PR labels Aug 5, 2026
@xen2
xen2 merged commit 7fa7e40 into stride3d:master Aug 5, 2026
88 of 92 checks passed
@xen2
xen2 deleted the feature/asset-not-found branch August 5, 2026 21:33
@IXLLEGACYIXL

Copy link
Copy Markdown
Collaborator

"(and 2 more)"
why not list all?

@xen2

xen2 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member Author

"(and 2 more)" why not list all?

I was afraid if loading a generic name like Texture or Scene and it matches hundreds of them in subfolder (i.e. Scene1\Scene Scene2\Scene and so on), it wouldn't be a great experience.
So it is limited to 5 (in practice I think 95% of cases there will be only 1 match).
For the context, it's just meant as a hint that needs developer intervention anyway. If this happens, something is seriously broken, and usually the right asset to load is obvious just looking at the assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-editor Run the GameStudio editor screenshot suite on this PR ci-enduser Run the end-user sample screenshot + packaging suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants