Skip to content

Commit fb64ad2

Browse files
committed
refactor: move shared error handling out
1 parent 01400a7 commit fb64ad2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/core/src/codewhisperer/util/zipUtil.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,15 @@ export class ZipUtil {
368368
language: this._language,
369369
}
370370
} catch (error) {
371-
getLogger().error('Zip error caused by: %O', error)
372-
throw error
371+
this.handleZipError(error)
373372
}
374373
}
375374

375+
protected handleZipError(e: unknown): never {
376+
getLogger().error('Zip error caused by: %s', e)
377+
throw new ProjectZipError(e instanceof Error ? e.message : 'Unknown error occurred during zip operation')
378+
}
379+
376380
public async generateZipTestGen(projectPath: string, initialExecution: boolean): Promise<ZipMetadata> {
377381
try {
378382
const zipDirPath = this.getZipDirPath()
@@ -421,10 +425,7 @@ export class ZipUtil {
421425
language: this._language,
422426
}
423427
} catch (error) {
424-
getLogger().error('Zip error caused by: %s', error)
425-
throw new ProjectZipError(
426-
error instanceof Error ? error.message : 'Unknown error occurred during zip operation'
427-
)
428+
this.handleZipError(error)
428429
}
429430
}
430431
// TODO: Refactor this

0 commit comments

Comments
 (0)