From 4ebcbb71da51ec091c8344180f6288340097cbd5 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 28 Mar 2026 10:41:29 +0000 Subject: [PATCH] error handling --- .../storage/drivers/local.driver.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/server/src/integrations/storage/drivers/local.driver.ts b/apps/server/src/integrations/storage/drivers/local.driver.ts index 90f7b7dd..39342c61 100644 --- a/apps/server/src/integrations/storage/drivers/local.driver.ts +++ b/apps/server/src/integrations/storage/drivers/local.driver.ts @@ -66,25 +66,25 @@ export class LocalDriver implements StorageDriver { } async readStream(filePath: string): Promise { - try { - return createReadStream(this._fullPath(filePath)); - } catch (err) { - throw new Error(`Failed to read file: ${(err as Error).message}`); + const fullPath = this._fullPath(filePath); + if (!(await fs.pathExists(fullPath))) { + throw new Error(`File not found: ${filePath}`); } + return createReadStream(fullPath); } async readRangeStream( filePath: string, range: { start: number; end: number }, ): Promise { - try { - return createReadStream(this._fullPath(filePath), { - start: range.start, - end: range.end, - }); - } catch (err) { - throw new Error(`Failed to read file: ${(err as Error).message}`); + const fullPath = this._fullPath(filePath); + if (!(await fs.pathExists(fullPath))) { + throw new Error(`File not found: ${filePath}`); } + return createReadStream(fullPath, { + start: range.start, + end: range.end, + }); } async exists(filePath: string): Promise {