refactor(engine): prefer `orElseThrow` on Option instead of try/catch
public LwjglCanvasRenderer(Context context) {
// TODO use context to get assets instead of static methods
- try {
- this.textureMat = Assets.getMaterial("engine:UITexture").get();
- } catch (java.util.NoSuchElementException noSuch) {
- // Some extra attention to how this is reported, because this is often the first asset we try to load.
- throw new RuntimeException("Failing to find engine textures", noSuch);
- }
+ this.textureMat =
+ Assets.getMaterial("engine:UITexture")
+ .orElseThrow(() -> new RuntimeException("Failing to find engine textures"));
this.billboard = Assets.getMesh("engine:UIBillboard").get();
this.fontMeshBuilder = new FontMeshBuilder(context.get(AssetManager.class).getAsset("engine:UIUnderline", Material.class).get());
// failure to load these can be due to failing shaders or missing resources
