From 9ca3f3d2b41ecfe33d84d6328aa02655386fbf8c Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 22 Dec 2022 19:58:53 +0800 Subject: [PATCH] add error check for failed to load --- lib/filament_controller.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/filament_controller.dart b/lib/filament_controller.dart index 87edc394..12d772ac 100644 --- a/lib/filament_controller.dart +++ b/lib/filament_controller.dart @@ -10,6 +10,7 @@ import 'package:flutter/services.dart'; // should make this consistent typedef FilamentAsset = int; typedef FilamentLight = int; +const FilamentAsset FILAMENT_ASSET_ERROR = 0; abstract class FilamentController { Size get size; @@ -230,6 +231,9 @@ class PolyvoxFilamentController extends FilamentController { Future loadGlb(String path) async { print("Loading GLB at $path "); var asset = await _channel.invokeMethod("loadGlb", path); + if (asset == FILAMENT_ASSET_ERROR) { + throw Exception("An error occurred loading the asset at $path"); + } return asset as FilamentAsset; }