From d3af1adab586043f3dd59c3a5935252dbca71511 Mon Sep 17 00:00:00 2001 From: jiasheng Date: Fri, 16 Jan 2026 07:59:29 +0800 Subject: [PATCH 1/2] fix: enhance error tracking for unhandled exceptions and datasource URL evaluation --- package.json | 2 +- src/index.ts | 3 +++ src/zmodel-parser.ts | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 95cda05..40bb59d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/proxy", - "version": "0.2.3", + "version": "0.2.4", "description": "A CLI tool to run an Express server that proxies CRUD requests to a ZenStack backend", "main": "index.js", "publishConfig": { diff --git a/src/index.ts b/src/index.ts index 93d4712..3f1730f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,11 +67,14 @@ export default async function () { // ignore exitCode = e.exitCode } else if (e instanceof CliError) { + telemetry.trackError(e) console.error(red(e.message)) } else { if (e instanceof Error) { + telemetry.trackError(e) console.error(red(`Unhandled error: ${e.message}`)) } else { + telemetry.trackError(new Error(String(e))) console.error(red(`Unhandled error: ${String(e)}`)) } } diff --git a/src/zmodel-parser.ts b/src/zmodel-parser.ts index 67813f4..d406a99 100644 --- a/src/zmodel-parser.ts +++ b/src/zmodel-parser.ts @@ -132,6 +132,9 @@ function parseDatasource( const urlFn = new Function('env', `return ${urlValueStr}`) url = urlFn(env) } catch (evalError) { + if (evalError instanceof CliError) { + throw evalError + } throw new CliError( 'Could not evaluate datasource url from schema, you could provide it via -d option.' ) From e13091fbc76b150b87c87cda5356ab0173c5c9ca Mon Sep 17 00:00:00 2001 From: jiasheng Date: Fri, 16 Jan 2026 08:21:34 +0800 Subject: [PATCH 2/2] fix: remove uncessary error tracking --- src/index.ts | 3 --- src/zmodel-parser.ts | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3f1730f..93d4712 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,14 +67,11 @@ export default async function () { // ignore exitCode = e.exitCode } else if (e instanceof CliError) { - telemetry.trackError(e) console.error(red(e.message)) } else { if (e instanceof Error) { - telemetry.trackError(e) console.error(red(`Unhandled error: ${e.message}`)) } else { - telemetry.trackError(new Error(String(e))) console.error(red(`Unhandled error: ${String(e)}`)) } } diff --git a/src/zmodel-parser.ts b/src/zmodel-parser.ts index d406a99..bc190c6 100644 --- a/src/zmodel-parser.ts +++ b/src/zmodel-parser.ts @@ -75,7 +75,7 @@ function loadPrismaConfig(schemaDir: string): string | null { const config = configFn(env) return config?.datasource?.url } catch (error) { - if (error instanceof Error && error.message.includes('Environment variable')) { + if (error instanceof Error) { throw error } console.warn(`Warning: Failed to parse prisma.config.ts: ${error}`) @@ -144,7 +144,7 @@ function parseDatasource( // If still no URL found, throw error if (url == null) { throw new CliError( - 'No datasource URL found. For Prisma 7, ensure prisma.config.ts exists with datasource configuration, or provide the URL via -d option.' + 'No datasource URL found. For Prisma 7, ensure prisma.config.ts exists with datasource configuration or directly provide the URL via -d option.' ) } }