From 8d27e1fd02c0b9efe18bbec3d50fb5f78bc3d657 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 21 Jan 2026 17:51:26 +0900 Subject: [PATCH] Add fallback to UseObject error handling The UseObject function now accepts an optional fallback callback, which is invoked if the main callback throws an error. This improves error handling and allows custom recovery logic. --- app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index c95b39b..e8c9c01 100644 --- a/app.js +++ b/app.js @@ -188,7 +188,7 @@ if (typeof CreateObject === "undefined") { } if (typeof UseObject === "undefined") { - var UseObject = function(progId, callback, dispose) { + var UseObject = function(progId, callback, dispose, fallback) { if (typeof callback !== "function") { return null; } @@ -204,6 +204,9 @@ if (typeof UseObject === "undefined") { var obj = CreateObject(progId); try { return callback(obj); + } catch (e) { + return (typeof fallback === "function" ? + fallback(obj, e) : null); } finally { dispose(obj); obj = null;