How should I handle missing resources?
- by concept3d
Your game expects a certain asset to be loaded, but it isn't found. How should the situation be handled? For example:
Texture* grassTexture = LoadTexture("Grass.png"); // returns NULL; texture not found
Mesh* car = LoadMesh("Car.obj"); // returns NULL; 3D mesh not found
It might have been accidentally deleted by the user, corrupted or misspelled while in development.
Some potential responses:
Assertions (ideally only during development)
Exit the game gracefully
Throw an exception and try to handle it.
Which way is best?