@betterer/errors
Advanced tools
Comparing version 1.0.2 to 1.2.0
import { BettererError } from './error'; | ||
import { BettererErrorFactory, BettererErrorMessageFactory } from './types'; | ||
export declare function logError(err: Error | BettererError): void; | ||
import { BettererErrorFactory, BettererErrorMessageFactory, ErrorLike } from './types'; | ||
export declare function logError(err: ErrorLike | Error | BettererError): void; | ||
export declare function registerError(factory: BettererErrorMessageFactory): BettererErrorFactory; |
@@ -11,11 +11,11 @@ "use strict"; | ||
var factory = ERROR_MESSAGES.get(err.code); | ||
var errors = err.details.filter(function (detail) { return detail instanceof Error; }); | ||
var messages = err.details.filter(function (detail) { return !(detail instanceof Error); }); | ||
var errors_1 = err.details.filter(function (detail) { return isErrorLike(detail); }); | ||
var messages = err.details.filter(function (detail) { return !errors_1.includes(detail); }); | ||
err.message = factory.apply(void 0, messages); | ||
logger_1.error(err.message); | ||
errors.forEach(logError); | ||
errors_1.forEach(logError); | ||
return; | ||
} | ||
logger_1.br(); | ||
console.error(err.message, err.stack); | ||
console.error(err.stack); | ||
logger_1.br(); | ||
@@ -41,2 +41,5 @@ } | ||
} | ||
function isErrorLike(err) { | ||
return err.message != null && err.stack !== null; | ||
} | ||
//# sourceMappingURL=error-handler.js.map |
@@ -5,1 +5,5 @@ import { BettererError } from './error'; | ||
export declare type BettererErrorMessageFactory = (...details: BettererErrorDetails) => string; | ||
export declare type ErrorLike = { | ||
message: string; | ||
stack: string; | ||
}; |
{ | ||
"name": "@betterer/errors", | ||
"description": "error handler for @betterer/betterer", | ||
"version": "1.0.2", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "db78ef726ff97b65fc4922acdf65a97e6aa7cc31" | ||
"gitHead": "7780911635fc418e46bb4b3f8c60eaf10578b710" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9060
96