From c0f5439522fc93e5ad7ced5b68b22aed38a8ab99 Mon Sep 17 00:00:00 2001 From: Dan Kadera Date: Fri, 8 Sep 2023 20:04:48 +0200 Subject: [PATCH] improve output diagnostic messages --- core/cli/package.json | 2 +- core/cli/src/checker.ts | 14 ++++++++++---- package-lock.json | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/cli/package.json b/core/cli/package.json index 2568fea..f4b98a8 100644 --- a/core/cli/package.json +++ b/core/cli/package.json @@ -9,7 +9,7 @@ "ioc", "inversion of control" ], - "version": "0.0.39", + "version": "0.0.40", "license": "MIT", "author": { "name": "Dan Kadera", diff --git a/core/cli/src/checker.ts b/core/cli/src/checker.ts index d496fe9..1f7e610 100644 --- a/core/cli/src/checker.ts +++ b/core/cli/src/checker.ts @@ -76,7 +76,7 @@ export class Checker { for (const diagnostic of output.getPreEmitDiagnostics()) { this.logger.log( this.getDiagnosticCategoryLogLevel(diagnostic.getCategory()), - this.formatDiagnostic(diagnostic.getLineNumber(), diagnostic.getMessageText()), + this.formatDiagnostic(diagnostic.getMessageText(), diagnostic.getLineNumber()), ); } } @@ -89,13 +89,19 @@ export class Checker { } } - private formatDiagnostic(line?: number, ...messages: (DiagnosticMessageChain | string)[]): string { + private formatDiagnostic(message: DiagnosticMessageChain | string, line?: number): string { + return line !== undefined + ? `line ${line} in compiled container: ${this.formatDiagnosticMessage(message)}` + : `in compiled container: ${this.formatDiagnosticMessage(message)}`; + } + + private formatDiagnosticMessage(...messages: (DiagnosticMessageChain | string)[]): string { return messages.map((message) => { if (typeof message === 'string') { - return line !== undefined ? `L${line}: ${message}` : message; + return message; } - return this.formatDiagnostic(line, message.getMessageText(), ...message.getNext() ?? []); + return this.formatDiagnosticMessage(message.getMessageText(), ...message.getNext() ?? []); }).join('\n'); } } diff --git a/package-lock.json b/package-lock.json index fc1e436..5190e14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ }, "core/cli": { "name": "dicc-cli", - "version": "0.0.39", + "version": "0.0.40", "license": "MIT", "dependencies": { "@debugr/console": "^3.0.0-rc.10",