A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix: replace silent catch blocks with diagnostic warnings across SDK
esenginecd1081400f92
diff --git a/sdk/src/app.ts b/sdk/src/app.tsindex b3678b4da..17bd7d736 100644--- a/sdk/src/app.ts+++ b/sdk/src/app.ts@@ -510,7 +510,7 @@ export class App {}for (const entity of this.world_.getAllEntities()) {- try { this.world_.despawn(entity); } catch (_) { /* ignore */ }+ try { this.world_.despawn(entity); } catch (e) { console.warn('[App] Shutdown despawn error:', e); }}this.world_.disconnectCpp();diff --git a/sdk/src/platform/wechat/index.ts b/sdk/src/platform/wechat/index.tsindex 84afbbbee..e37b93b68 100644--- a/sdk/src/platform/wechat/index.ts+++ b/sdk/src/platform/wechat/index.ts@@ -149,16 +149,16 @@ class WeChatPlatformAdapter implements PlatformAdapter {setStorageItem(key: string, value: string): void {try {wx.setStorageSync(key, value);- } catch {- // silent fail+ } catch (e) {+ console.warn('[WeChat] setStorageSync failed:', e);}}removeStorageItem(key: string): void {try {wx.removeStorageSync(key);- } catch {- // silent fail+ } catch (e) {+ console.warn('[WeChat] removeStorageSync failed:', e);}}@@ -170,8 +170,8 @@ class WeChatPlatformAdapter implements PlatformAdapter {wx.removeStorageSync(k);}}- } catch {- // silent fail+ } catch (e) {+ console.warn('[WeChat] clearStorage failed:', e);}}}diff --git a/sdk/src/runtimeLoader.ts b/sdk/src/runtimeLoader.tsindex 023cc963b..f19a4d65f 100644--- a/sdk/src/runtimeLoader.ts+++ b/sdk/src/runtimeLoader.ts@@ -183,7 +183,8 @@ function writeToVirtualFS(module: ESEngineModule, virtualPath: string, data: strensureVirtualDir(module, virtualPath);fs.writeFile(virtualPath, data);return true;- } catch {+ } catch (e) {+ console.warn(`[Runtime] Failed to write virtual FS: ${virtualPath}`, e);return false;}}@@ -318,7 +319,8 @@ async function loadBitmapFonts(const rm = module.getResourceManager();cache[ref] = rm.loadBitmapFont(fntContent, texHandle, pixels.width, pixels.height);- } catch {+ } catch (e) {+ console.warn(`[Runtime] Failed to load bitmap font: ${ref}`, e);cache[ref] = 0;}}@@ -358,7 +360,8 @@ async function loadMaterials(shaderCache[shaderKey] = shaderHandle;}materialCache[matRef] = Material.createFromAsset(matData, shaderHandle);- } catch {+ } catch (e) {+ console.warn(`[Runtime] Failed to load material: ${matRef}`, e);materialCache[matRef] = 0;}}@@ -435,7 +438,8 @@ async function loadAnimClips(try {const result = await provider.loadPixels(texPath);textureHandles.set(texPath, createTextureFromPixels(module, result));- } catch {+ } catch (e) {+ console.warn(`[Runtime] Failed to load anim texture: ${texPath}`, e);textureHandles.set(texPath, 0);}}@@ -483,8 +487,8 @@ async function loadTilemaps(const result = await provider.loadPixels(imagePath);textureHandle = createTextureFromPixels(module, result);registerTextureDimensions(textureHandle, result.width, result.height);- } catch {- /* skip missing tileset texture */+ } catch (e) {+ console.warn(`[Runtime] Failed to load tileset texture: ${imagePath}`, e);}tilesets.push({ textureHandle, columns: ts.columns });}diff --git a/sdk/src/spine/SpineController.ts b/sdk/src/spine/SpineController.tsindex 47eb33105..289789b53 100644--- a/sdk/src/spine/SpineController.ts+++ b/sdk/src/spine/SpineController.ts@@ -123,7 +123,8 @@ export class SpineModuleController {const json = this.api_.getAnimations(instanceId);try {return JSON.parse(json);- } catch {+ } catch (e) {+ console.warn('[Spine] Failed to parse animations JSON', e);return [];}}@@ -132,7 +133,8 @@ export class SpineModuleController {const json = this.api_.getSkins(instanceId);try {return JSON.parse(json);- } catch {+ } catch (e) {+ console.warn('[Spine] Failed to parse skins JSON', e);return [];}}diff --git a/sdk/src/storage.ts b/sdk/src/storage.tsindex fb1c051ba..3fe1f0112 100644--- a/sdk/src/storage.ts+++ b/sdk/src/storage.ts@@ -38,7 +38,8 @@ export const Storage = {if (raw === null) return defaultValue;try {return JSON.parse(raw) as T;- } catch {+ } catch (e) {+ console.warn(`[Storage] Failed to parse JSON for key "${key}"`, e);return defaultValue;}},diff --git a/sdk/src/tilemap/tiledLoader.ts b/sdk/src/tilemap/tiledLoader.tsindex 415f1014a..90d3b4df6 100644--- a/sdk/src/tilemap/tiledLoader.ts+++ b/sdk/src/tilemap/tiledLoader.ts@@ -354,7 +354,8 @@ export async function parseTiledMap(api.tiled_freeMap(handle);return result;- } catch {+ } catch (e) {+ console.warn('[Tiled] Failed to parse tilemap', e);api.tiled_freeMap(handle);return null;}diff --git a/sdk/src/world.ts b/sdk/src/world.tsindex 7fcc7ee62..9044b6eec 100644--- a/sdk/src/world.ts+++ b/sdk/src/world.ts@@ -388,7 +388,7 @@ export class World {this.worldVersion_++;for (const cb of this.spawnCallbacks_) {- try { cb(entity); } catch {}+ try { cb(entity); } catch (e) { console.warn('[World] Spawn callback error:', e); }}return entity;@@ -403,7 +403,7 @@ export class World {}for (const cb of this.despawnCallbacks_) {- try { cb(entity); } catch {}+ try { cb(entity); } catch (e) { console.warn('[World] Despawn callback error:', e); }}if (this.cppRegistry_) {@@ -909,7 +909,7 @@ export class World {getComponentTypes(entity: Entity): string[] {const types = new Set<string>();for (const [name, methods] of this.builtinMethodCache_) {- try { if (methods.has(entity)) types.add(name); } catch {}+ try { if (methods.has(entity)) types.add(name); } catch (e) { console.warn(`[World] Component check failed for ${name}:`, e); }}if (this.cppRegistry_) {for (const [name, comp] of getAllRegisteredComponents()) {@@ -917,7 +917,7 @@ export class World {try {const m = this.getBuiltinMethods(comp._cppName);if (m.has(entity)) types.add(name);- } catch {}+ } catch (e) { console.warn(`[World] Builtin check failed for ${name}:`, e); }}}}