@lokalise/node-core
Advanced tools
Comparing version 6.2.0 to 6.3.0
@@ -12,1 +12,2 @@ export declare const globalLogger: import("pino").Logger<import("pino").LoggerOptions | import("pino").DestinationStream>; | ||
export declare function executeAsyncAndHandleGlobalErrors<T>(operation: () => Promise<T>, stopOnError?: boolean): Promise<T | undefined>; | ||
export declare function executeSettleAllAndHandleGlobalErrors(promises: Promise<unknown>[], stopOnError?: boolean): Promise<PromiseSettledResult<unknown>[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.executeAsyncAndHandleGlobalErrors = exports.executeAndHandleGlobalErrors = exports.resolveGlobalErrorLogObject = exports.globalLogger = void 0; | ||
exports.executeSettleAllAndHandleGlobalErrors = exports.executeAsyncAndHandleGlobalErrors = exports.executeAndHandleGlobalErrors = exports.resolveGlobalErrorLogObject = exports.globalLogger = void 0; | ||
const node_util_1 = require("node:util"); | ||
@@ -47,2 +47,18 @@ const pino_1 = require("pino"); | ||
exports.executeAsyncAndHandleGlobalErrors = executeAsyncAndHandleGlobalErrors; | ||
async function executeSettleAllAndHandleGlobalErrors(promises, stopOnError = true) { | ||
const result = await Promise.allSettled(promises); | ||
let errorsHappened; | ||
for (const entry of result) { | ||
if (entry.status === 'rejected') { | ||
const logObject = resolveGlobalErrorLogObject(entry.reason); | ||
exports.globalLogger.error(logObject); | ||
errorsHappened = true; | ||
} | ||
} | ||
if (stopOnError && errorsHappened) { | ||
process.exit(1); | ||
} | ||
return result; | ||
} | ||
exports.executeSettleAllAndHandleGlobalErrors = executeSettleAllAndHandleGlobalErrors; | ||
//# sourceMappingURL=globalErrorHandler.js.map |
{ | ||
"name": "@lokalise/node-core", | ||
"version": "6.2.0", | ||
"version": "6.3.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Lokalise", |
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
217726
2668