diff --git a/CHANGELOG.md b/CHANGELOG.md index a3d58d07b..7533ea647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to the "prettier-vscode" extension will be documented in thi +## [5.1.3] + +- Improved error output of certain plugin exceptions. + ## [5.1.2] - Added error logging for unusual prettier exceptions. diff --git a/package.json b/package.json index c9c70b7df..8c3fcdc9f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "prettier-vscode", "displayName": "Prettier - Code formatter", "description": "Code formatter using prettier", - "version": "5.1.2", + "version": "5.1.3", "publisher": "esbenp", "author": "Prettier <@prettiercode>", "galleryBanner": { diff --git a/src/LoggingService.ts b/src/LoggingService.ts index 100734c37..b28247e34 100644 --- a/src/LoggingService.ts +++ b/src/LoggingService.ts @@ -46,13 +46,16 @@ export class LoggingService { } } - public logError(message: string, error?: Error) { + public logError(message: string, error?: Error | string) { if (this.logLevel === "NONE") { return; } this.logMessage(message, "ERROR"); - if (error?.message || error?.stack) { - // Try to print the most useful error message + if (typeof error === "string") { + // Errors as a string usually only happen with + // plugins that don't return the expected error. + this.outputChannel.appendLine(error); + } else if (error?.message || error?.stack) { if (error?.message) { this.logMessage(error.message, "ERROR"); } @@ -60,7 +63,6 @@ export class LoggingService { this.outputChannel.appendLine(error.stack); } } else if (error) { - // Weird error returned, just output the whole thing this.logObject(error); } }