From ce41ab90e7e9d1fb92cabbd9cf8ba02b819bda14 Mon Sep 17 00:00:00 2001 From: Kenta HATTORI Date: Sat, 26 Oct 2024 22:16:17 +0900 Subject: [PATCH] Changed to continue processing on error --- src/commands/rm.ts | 6 ++++-- src/commands/rmdir.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands/rm.ts b/src/commands/rm.ts index cb14809..924bb28 100644 --- a/src/commands/rm.ts +++ b/src/commands/rm.ts @@ -56,11 +56,13 @@ export default class Rm extends Command { if (!options.force) { const result = await KeClient.get(this.conf, target) if (result === null) { - throw new Error(`failed to remove: '${target}' is not found`) + this.warn(`failed to remove: '${target}' is not found`) + return } if (result.type_object === DIRECTORY_TYPE) { - throw new Error(`failed to remove: '${target}' is a directory`) + this.warn(`failed to remove: '${target}' is a directory`) + return } } diff --git a/src/commands/rmdir.ts b/src/commands/rmdir.ts index 8e09279..7fc40ff 100644 --- a/src/commands/rmdir.ts +++ b/src/commands/rmdir.ts @@ -56,17 +56,20 @@ export default class Rmdir extends Command { const result = await KeClient.get(this.conf, targetDir) if (result === null) { - throw new Error(`failed to remove directory: '${targetDir}' is not found`) + this.warn(`failed to remove directory: '${targetDir}' is not found`) + return } if (result.type_object !== DIRECTORY_TYPE) { - throw new Error(`failed to remove directory: '${targetDir}' is not a directory`) + this.warn(`failed to remove directory: '${targetDir}' is not a directory`) + return } // ディレクトリが空かどうかチェックする const results = await KeClient.getAll(this.conf, `${targetDir}.children`) if (results!.count > 0) { - throw new Error(`failed to remove directory: '${targetDir}' is not empty`) + this.warn(`failed to remove directory: '${targetDir}' is not empty`) + return } await KeClient.del(this.conf, targetDir)