From 399ea14e0d238ce782e5a45696870510b27de5b8 Mon Sep 17 00:00:00 2001 From: gaochao Date: Thu, 19 Jun 2025 20:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8DAsyncCallback=20Signed-off-by?= =?UTF-8?q?:=20gaochao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/ets/ani/ets/@ohos.configPolicy.ets | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/interfaces/ets/ani/ets/@ohos.configPolicy.ets b/interfaces/ets/ani/ets/@ohos.configPolicy.ets index 65a6f41..16929ba 100644 --- a/interfaces/ets/ani/ets/@ohos.configPolicy.ets +++ b/interfaces/ets/ani/ets/@ohos.configPolicy.ets @@ -37,11 +37,9 @@ namespace configPolicy { taskpool.execute((): string => { return getOneCfgFileSync(relPath); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as string); + callback(null, content as string); }).catch((err: NullishType) : void => { - callback(err as BusinessError, ""); + callback(err as BusinessError, undefined); }); } @@ -49,11 +47,9 @@ namespace configPolicy { taskpool.execute((): string => { return getOneCfgFileSync(relPath, followMode); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as string); + callback(null, content as string); }).catch((err: NullishType) : void => { - callback(err as BusinessError, ""); + callback(err as BusinessError, undefined); }); } @@ -62,11 +58,9 @@ namespace configPolicy { taskpool.execute((): string => { return getOneCfgFileSync(relPath, followMode, extra); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as string); + callback(null, content as string); }).catch((err: NullishType) : void => { - callback(err as BusinessError, ""); + callback(err as BusinessError, undefined); }); } @@ -98,11 +92,9 @@ namespace configPolicy { taskpool.execute((): Array => { return getCfgFilesSync(relPath); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as Array); + callback(null, content as Array); }).catch((err: NullishType) : void => { - callback(err as BusinessError, new Array); + callback(err as BusinessError, undefined); }); } @@ -110,11 +102,9 @@ namespace configPolicy { taskpool.execute((): Array => { return getCfgFilesSync(relPath, followMode); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as Array); + callback(null, content as Array); }).catch((err: NullishType) : void => { - callback(err as BusinessError, new Array); + callback(err as BusinessError, undefined); }); } @@ -123,11 +113,9 @@ namespace configPolicy { taskpool.execute((): Array => { return getCfgFilesSync(relPath, followMode, extra); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as Array); + callback(null, content as Array); }).catch((err: NullishType) : void => { - callback(err as BusinessError, new Array); + callback(err as BusinessError, undefined); }); } @@ -159,11 +147,9 @@ namespace configPolicy { taskpool.execute((): Array => { return getCfgDirListSync(); }).then((content: NullishType) => { - let error = new BusinessError - error.code = 0 - callback(error, content as Array); + callback(null, content as Array); }).catch((err: NullishType) : void => { - callback(err as BusinessError, new Array); + callback(err as BusinessError, undefined); }); } -- Gitee