Refactoring: Simplify retrieving error message

This commit is contained in:
Henry Mercer
2024-09-16 22:38:35 +02:00
parent bbd7c801a0
commit dd7307d603
54 changed files with 106 additions and 89 deletions

View File

@@ -998,8 +998,14 @@ export function wrapError(error: unknown): Error {
return error instanceof Error ? error : new Error(String(error));
}
/**
* Returns an appropriate message for the error.
*
* If the error is an `Error` instance, this returns the error message without
* an `Error: ` prefix.
*/
export function getErrorMessage(error: unknown): string {
return error instanceof Error ? error.toString() : String(error);
return error instanceof Error ? error.message : String(error);
}
export function prettyPrintPack(pack: Pack) {