Refactoring: Simplify retrieving error message
This commit is contained in:
parent
bbd7c801a0
commit
dd7307d603
54 changed files with 106 additions and 89 deletions
8
lib/util.js
generated
8
lib/util.js
generated
|
|
@ -784,8 +784,14 @@ function fixInvalidNotificationsInFile(inputPath, outputPath, logger) {
|
|||
function wrapError(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.
|
||||
*/
|
||||
function getErrorMessage(error) {
|
||||
return error instanceof Error ? error.toString() : String(error);
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
}
|
||||
function prettyPrintPack(pack) {
|
||||
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${pack.path ? `:${pack.path}` : ""}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue