opticore-catch-exception-error 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +111 -95
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +106 -93
- package/example/index.ts +17 -2
- package/package.json +1 -1
- package/tsconfig.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -44,11 +44,14 @@ __export(index_exports, {
|
|
|
44
44
|
StackTraceSyntaxError: () => StackTraceSyntaxError,
|
|
45
45
|
StackTraceSystemError: () => StackTraceSystemError,
|
|
46
46
|
StackTraceTypeError: () => StackTraceTypeError,
|
|
47
|
-
StackTraceURIError: () => StackTraceURIError
|
|
48
|
-
translateCatchExceptionErrorLanguageLoader: () => translateCatchExceptionErrorLanguageLoader
|
|
47
|
+
StackTraceURIError: () => StackTraceURIError
|
|
49
48
|
});
|
|
50
49
|
module.exports = __toCommonJS(index_exports);
|
|
51
50
|
|
|
51
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
52
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
53
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
54
|
+
|
|
52
55
|
// src/domains/constants/errorName.constant.ts
|
|
53
56
|
var CErrorName = {
|
|
54
57
|
evalError: "EvalError",
|
|
@@ -92,6 +95,9 @@ var CEventNameError = {
|
|
|
92
95
|
|
|
93
96
|
// src/core/errors/base/stackTraceError.ts
|
|
94
97
|
var StackTraceError = class extends Error {
|
|
98
|
+
name;
|
|
99
|
+
httpCode;
|
|
100
|
+
isOperational;
|
|
95
101
|
/**
|
|
96
102
|
*
|
|
97
103
|
* @param props
|
|
@@ -196,27 +202,47 @@ var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
|
196
202
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
197
203
|
var import_opticore_logger = require("opticore-logger");
|
|
198
204
|
var import_opticore_http_response11 = require("opticore-http-response");
|
|
199
|
-
var
|
|
205
|
+
var import_opticore_translator2 = require("opticore-translator");
|
|
200
206
|
|
|
201
207
|
// src/utils/dateTimeFormatted.utils.ts
|
|
202
208
|
var dateTimeFormatted = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
203
209
|
|
|
204
210
|
// src/core/errors/events/serverListen.event.error.ts
|
|
211
|
+
var import_opticore_env_access2 = require("opticore-env-access");
|
|
212
|
+
|
|
213
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
214
|
+
var import_path = __toESM(require("path"), 1);
|
|
215
|
+
var import_opticore_translator = require("opticore-translator");
|
|
205
216
|
var import_opticore_env_access = require("opticore-env-access");
|
|
217
|
+
var import_url = require("url");
|
|
218
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
219
|
+
const __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
220
|
+
const __dirname = import_path.default.dirname(__filename2);
|
|
221
|
+
const translateMsgJsonFilePath = import_path.default.join(__dirname, "../../../", "utils", "translations");
|
|
222
|
+
import_opticore_translator.TranslationLoader.loadTranslations(translateMsgJsonFilePath, import_opticore_env_access.getEnvVariable.defaultLocal);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// src/core/errors/events/serverListen.event.error.ts
|
|
206
226
|
var ServerListenEventError = class {
|
|
227
|
+
static logger = new import_opticore_logger.LoggerCore();
|
|
228
|
+
static stackTrace;
|
|
229
|
+
static __init() {
|
|
230
|
+
translateCatchExceptionErrorLanguageLoader();
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
207
233
|
/**
|
|
208
234
|
*
|
|
209
235
|
*/
|
|
210
236
|
static hostPortUndefined() {
|
|
211
237
|
this.stackTrace = this.traceError(
|
|
212
|
-
|
|
213
|
-
|
|
238
|
+
import_opticore_translator2.TranslationLoader.t("errorHostUrl", import_opticore_translator2.CLocal),
|
|
239
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
214
240
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
215
241
|
);
|
|
216
242
|
this.logger.error(
|
|
217
243
|
this.stackTrace.message,
|
|
218
|
-
|
|
219
|
-
|
|
244
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
245
|
+
import_opticore_translator2.TranslationLoader.t("badPort", import_opticore_translator2.CLocal, { badPort: import_opticore_env_access2.getEnvVariable.appPort }),
|
|
220
246
|
this.stackTrace.stack,
|
|
221
247
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
222
248
|
);
|
|
@@ -227,14 +253,14 @@ var ServerListenEventError = class {
|
|
|
227
253
|
*/
|
|
228
254
|
static hostUndefined() {
|
|
229
255
|
this.stackTrace = this.traceError(
|
|
230
|
-
|
|
231
|
-
|
|
256
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal, { badHost: import_opticore_env_access2.getEnvVariable.appHost }),
|
|
257
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
232
258
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
233
259
|
);
|
|
234
260
|
this.logger.error(
|
|
235
261
|
this.stackTrace.message,
|
|
236
|
-
|
|
237
|
-
|
|
262
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
263
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal),
|
|
238
264
|
this.stackTrace.stack,
|
|
239
265
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
240
266
|
);
|
|
@@ -245,14 +271,14 @@ var ServerListenEventError = class {
|
|
|
245
271
|
*/
|
|
246
272
|
static portUndefined() {
|
|
247
273
|
this.stackTrace = this.traceError(
|
|
248
|
-
|
|
249
|
-
|
|
274
|
+
import_opticore_translator2.TranslationLoader.t("badPort", import_opticore_translator2.CLocal),
|
|
275
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
250
276
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
251
277
|
);
|
|
252
278
|
this.logger.error(
|
|
253
279
|
this.stackTrace.message,
|
|
254
|
-
|
|
255
|
-
|
|
280
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
281
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal),
|
|
256
282
|
this.stackTrace.stack,
|
|
257
283
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
258
284
|
);
|
|
@@ -264,9 +290,9 @@ var ServerListenEventError = class {
|
|
|
264
290
|
*/
|
|
265
291
|
static onEventError(err) {
|
|
266
292
|
this.logger.error(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
293
|
+
import_opticore_translator2.TranslationLoader.t(err.message, import_opticore_translator2.CLocal),
|
|
294
|
+
import_opticore_translator2.TranslationLoader.t("serverStart", import_opticore_translator2.CLocal),
|
|
295
|
+
import_opticore_translator2.TranslationLoader.t("serverStartError", import_opticore_translator2.CLocal, { err }),
|
|
270
296
|
err.stack,
|
|
271
297
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
272
298
|
);
|
|
@@ -295,14 +321,14 @@ var ServerListenEventError = class {
|
|
|
295
321
|
*/
|
|
296
322
|
static processBeforeExit(code) {
|
|
297
323
|
this.stackTrace = this.traceError(
|
|
298
|
-
|
|
299
|
-
|
|
324
|
+
import_opticore_translator2.TranslationLoader.t("processExitCode", import_opticore_translator2.CLocal, { processExitCode: code }),
|
|
325
|
+
import_opticore_translator2.TranslationLoader.t("beforeExit", import_opticore_translator2.CLocal),
|
|
300
326
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
301
327
|
);
|
|
302
328
|
this.logger.error(
|
|
303
329
|
this.stackTrace.message,
|
|
304
|
-
|
|
305
|
-
|
|
330
|
+
import_opticore_translator2.TranslationLoader.t("beforeExit", import_opticore_translator2.CLocal),
|
|
331
|
+
import_opticore_translator2.TranslationLoader.t("processBeforeExit", import_opticore_translator2.CLocal),
|
|
306
332
|
this.stackTrace.stack,
|
|
307
333
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
308
334
|
);
|
|
@@ -313,14 +339,14 @@ var ServerListenEventError = class {
|
|
|
313
339
|
*/
|
|
314
340
|
static processDisconnected() {
|
|
315
341
|
this.stackTrace = this.traceError(
|
|
316
|
-
|
|
317
|
-
|
|
342
|
+
import_opticore_translator2.TranslationLoader.t("childProcessDiscon", import_opticore_translator2.CLocal),
|
|
343
|
+
import_opticore_translator2.TranslationLoader.t("processDiscon", import_opticore_translator2.CLocal),
|
|
318
344
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
319
345
|
);
|
|
320
346
|
this.logger.error(
|
|
321
347
|
this.stackTrace.message,
|
|
322
|
-
|
|
323
|
-
|
|
348
|
+
import_opticore_translator2.TranslationLoader.t("disconnected"),
|
|
349
|
+
import_opticore_translator2.TranslationLoader.t("processDiscon"),
|
|
324
350
|
this.stackTrace.stack,
|
|
325
351
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
326
352
|
);
|
|
@@ -334,25 +360,25 @@ var ServerListenEventError = class {
|
|
|
334
360
|
switch (code) {
|
|
335
361
|
case 0:
|
|
336
362
|
this.logger.success(
|
|
337
|
-
|
|
338
|
-
|
|
363
|
+
import_opticore_translator2.TranslationLoader.t("completed", import_opticore_translator2.CLocal, { code }),
|
|
364
|
+
import_opticore_translator2.TranslationLoader.t("finishingProcessWell", import_opticore_translator2.CLocal, { code })
|
|
339
365
|
);
|
|
340
366
|
console.log("");
|
|
341
367
|
const paddingLength = 35;
|
|
342
368
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
343
369
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
344
|
-
console.log(`${import_ansi_colors.default.bgGreen(` ${
|
|
370
|
+
console.log(`${import_ansi_colors.default.bgGreen(` ${import_opticore_translator2.TranslationLoader.t("serverStopped", import_opticore_translator2.CLocal)} `)}`);
|
|
345
371
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
346
372
|
break;
|
|
347
373
|
case 1:
|
|
348
374
|
this.stackTrace = this.traceError(
|
|
349
|
-
|
|
350
|
-
|
|
375
|
+
import_opticore_translator2.TranslationLoader.t("somethingWentWrong", import_opticore_translator2.CLocal),
|
|
376
|
+
import_opticore_translator2.TranslationLoader.t("genErrors", import_opticore_translator2.CLocal),
|
|
351
377
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
352
378
|
);
|
|
353
379
|
this.logger.error(
|
|
354
380
|
this.stackTrace.message,
|
|
355
|
-
|
|
381
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
356
382
|
"General Errors",
|
|
357
383
|
this.stackTrace.stack,
|
|
358
384
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -360,27 +386,27 @@ var ServerListenEventError = class {
|
|
|
360
386
|
break;
|
|
361
387
|
case 2:
|
|
362
388
|
this.stackTrace = this.traceError(
|
|
363
|
-
|
|
364
|
-
|
|
389
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
390
|
+
import_opticore_translator2.TranslationLoader.t("misuseShell", import_opticore_translator2.CLocal),
|
|
365
391
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
366
392
|
);
|
|
367
393
|
this.logger.error(
|
|
368
394
|
this.stackTrace.message,
|
|
369
|
-
|
|
370
|
-
|
|
395
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
396
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
371
397
|
this.stackTrace.stack,
|
|
372
398
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
373
399
|
);
|
|
374
400
|
break;
|
|
375
401
|
case 126:
|
|
376
402
|
this.stackTrace = this.traceError(
|
|
377
|
-
|
|
378
|
-
|
|
403
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
404
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotExecutable", import_opticore_translator2.CLocal),
|
|
379
405
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
380
406
|
);
|
|
381
407
|
this.logger.error(
|
|
382
408
|
this.stackTrace.message,
|
|
383
|
-
|
|
409
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
384
410
|
this.stackTrace.name,
|
|
385
411
|
this.stackTrace.stack,
|
|
386
412
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -388,13 +414,13 @@ var ServerListenEventError = class {
|
|
|
388
414
|
break;
|
|
389
415
|
case 127:
|
|
390
416
|
this.stackTrace = this.traceError(
|
|
391
|
-
|
|
392
|
-
|
|
417
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFound", import_opticore_translator2.CLocal),
|
|
418
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFoundInSystemPath", import_opticore_translator2.CLocal),
|
|
393
419
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
394
420
|
);
|
|
395
421
|
this.logger.error(
|
|
396
422
|
this.stackTrace.message,
|
|
397
|
-
|
|
423
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
398
424
|
this.stackTrace.name,
|
|
399
425
|
this.stackTrace.stack,
|
|
400
426
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -402,13 +428,13 @@ var ServerListenEventError = class {
|
|
|
402
428
|
break;
|
|
403
429
|
case 128:
|
|
404
430
|
this.stackTrace = this.traceError(
|
|
405
|
-
|
|
406
|
-
|
|
431
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFoundInSystemPath", import_opticore_translator2.CLocal),
|
|
432
|
+
import_opticore_translator2.TranslationLoader.t("argInvalid", import_opticore_translator2.CLocal),
|
|
407
433
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
408
434
|
);
|
|
409
435
|
this.logger.error(
|
|
410
436
|
this.stackTrace.message,
|
|
411
|
-
|
|
437
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
412
438
|
this.stackTrace.name,
|
|
413
439
|
this.stackTrace.stack,
|
|
414
440
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -416,13 +442,13 @@ var ServerListenEventError = class {
|
|
|
416
442
|
break;
|
|
417
443
|
case 130:
|
|
418
444
|
this.stackTrace = this.traceError(
|
|
419
|
-
|
|
420
|
-
|
|
445
|
+
import_opticore_translator2.TranslationLoader.t("scriptEndedManuallyByCtrlC", import_opticore_translator2.CLocal),
|
|
446
|
+
import_opticore_translator2.TranslationLoader.t("scriptEnded", import_opticore_translator2.CLocal),
|
|
421
447
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
422
448
|
);
|
|
423
449
|
this.logger.error(
|
|
424
450
|
this.stackTrace.message,
|
|
425
|
-
|
|
451
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
426
452
|
this.stackTrace.name,
|
|
427
453
|
this.stackTrace.stack,
|
|
428
454
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -430,13 +456,13 @@ var ServerListenEventError = class {
|
|
|
430
456
|
break;
|
|
431
457
|
case 137:
|
|
432
458
|
this.stackTrace = this.traceError(
|
|
433
|
-
|
|
459
|
+
import_opticore_translator2.TranslationLoader.t("processEndedBySIGKILL", import_opticore_translator2.CLocal),
|
|
434
460
|
"SIGKILL",
|
|
435
461
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
436
462
|
);
|
|
437
463
|
this.logger.error(
|
|
438
464
|
this.stackTrace.message,
|
|
439
|
-
|
|
465
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
440
466
|
this.stackTrace.name,
|
|
441
467
|
this.stackTrace.stack,
|
|
442
468
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -444,13 +470,13 @@ var ServerListenEventError = class {
|
|
|
444
470
|
break;
|
|
445
471
|
case 139:
|
|
446
472
|
this.stackTrace = this.traceError(
|
|
447
|
-
|
|
448
|
-
|
|
473
|
+
import_opticore_translator2.TranslationLoader.t("accessProcessIllegally", import_opticore_translator2.CLocal),
|
|
474
|
+
import_opticore_translator2.TranslationLoader.t("defaultSegment", import_opticore_translator2.CLocal),
|
|
449
475
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
450
476
|
);
|
|
451
477
|
this.logger.error(
|
|
452
478
|
this.stackTrace.message,
|
|
453
|
-
|
|
479
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
454
480
|
this.stackTrace.name,
|
|
455
481
|
this.stackTrace.stack,
|
|
456
482
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -458,13 +484,13 @@ var ServerListenEventError = class {
|
|
|
458
484
|
break;
|
|
459
485
|
case 143:
|
|
460
486
|
this.stackTrace = this.traceError(
|
|
461
|
-
|
|
462
|
-
|
|
487
|
+
import_opticore_translator2.TranslationLoader.t("processReceivedSigtermSignal", import_opticore_translator2.CLocal),
|
|
488
|
+
import_opticore_translator2.TranslationLoader.t("processReceived", import_opticore_translator2.CLocal),
|
|
463
489
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
464
490
|
);
|
|
465
491
|
this.logger.error(
|
|
466
492
|
this.stackTrace.message,
|
|
467
|
-
|
|
493
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
468
494
|
this.stackTrace.name,
|
|
469
495
|
this.stackTrace.stack,
|
|
470
496
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -472,13 +498,13 @@ var ServerListenEventError = class {
|
|
|
472
498
|
break;
|
|
473
499
|
case 255:
|
|
474
500
|
this.stackTrace = this.traceError(
|
|
475
|
-
|
|
476
|
-
|
|
501
|
+
import_opticore_translator2.TranslationLoader.t("exitCode", import_opticore_translator2.CLocal),
|
|
502
|
+
import_opticore_translator2.TranslationLoader.t("outRange", import_opticore_translator2.CLocal),
|
|
477
503
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
478
504
|
);
|
|
479
505
|
this.logger.error(
|
|
480
506
|
this.stackTrace.message,
|
|
481
|
-
|
|
507
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
482
508
|
this.stackTrace.name,
|
|
483
509
|
this.stackTrace.stack,
|
|
484
510
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -486,13 +512,13 @@ var ServerListenEventError = class {
|
|
|
486
512
|
break;
|
|
487
513
|
default:
|
|
488
514
|
this.stackTrace = this.traceError(
|
|
489
|
-
|
|
490
|
-
|
|
515
|
+
import_opticore_translator2.TranslationLoader.t("errorOccurring", import_opticore_translator2.CLocal),
|
|
516
|
+
import_opticore_translator2.TranslationLoader.t("errors", import_opticore_translator2.CLocal),
|
|
491
517
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
492
518
|
);
|
|
493
519
|
this.logger.error(
|
|
494
520
|
this.stackTrace.message,
|
|
495
|
-
|
|
521
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
496
522
|
this.stackTrace.name,
|
|
497
523
|
this.stackTrace.stack,
|
|
498
524
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -507,8 +533,8 @@ var ServerListenEventError = class {
|
|
|
507
533
|
static promiseRejectionHandled(promise) {
|
|
508
534
|
try {
|
|
509
535
|
this.stackTrace = this.traceError(
|
|
510
|
-
|
|
511
|
-
|
|
536
|
+
import_opticore_translator2.TranslationLoader.t("promise", import_opticore_translator2.CLocal, { promise }),
|
|
537
|
+
import_opticore_translator2.TranslationLoader.t("rejectionPromise", import_opticore_translator2.CLocal, { promise }),
|
|
512
538
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
513
539
|
);
|
|
514
540
|
this.logger.error(
|
|
@@ -530,8 +556,8 @@ var ServerListenEventError = class {
|
|
|
530
556
|
console.log("");
|
|
531
557
|
} else {
|
|
532
558
|
this.stackTrace = this.traceError(
|
|
533
|
-
|
|
534
|
-
|
|
559
|
+
import_opticore_translator2.TranslationLoader.t(error.message),
|
|
560
|
+
import_opticore_translator2.TranslationLoader.t("uncaughtExceptionHandled", import_opticore_translator2.CLocal),
|
|
535
561
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
536
562
|
);
|
|
537
563
|
this.logger.error(
|
|
@@ -559,8 +585,8 @@ var ServerListenEventError = class {
|
|
|
559
585
|
*/
|
|
560
586
|
static unhandledRejection(reason, promise) {
|
|
561
587
|
this.stackTrace = this.traceError(
|
|
562
|
-
|
|
563
|
-
|
|
588
|
+
import_opticore_translator2.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator2.CLocal, { promise, reason }),
|
|
589
|
+
import_opticore_translator2.TranslationLoader.t("unhandledRejection", import_opticore_translator2.CLocal, { promise, reason }),
|
|
564
590
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
565
591
|
);
|
|
566
592
|
this.logger.error(
|
|
@@ -577,13 +603,13 @@ var ServerListenEventError = class {
|
|
|
577
603
|
*/
|
|
578
604
|
static warning(warning) {
|
|
579
605
|
this.stackTrace = this.traceError(
|
|
580
|
-
|
|
606
|
+
import_opticore_translator2.TranslationLoader.t(warning.message, import_opticore_translator2.CLocal),
|
|
581
607
|
"warning",
|
|
582
608
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
583
609
|
);
|
|
584
610
|
this.logger.error(
|
|
585
611
|
this.stackTrace.message,
|
|
586
|
-
|
|
612
|
+
import_opticore_translator2.TranslationLoader.t("warning", import_opticore_translator2.CLocal, { warning }),
|
|
587
613
|
this.stackTrace.name,
|
|
588
614
|
this.stackTrace.stack,
|
|
589
615
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -595,8 +621,8 @@ var ServerListenEventError = class {
|
|
|
595
621
|
*/
|
|
596
622
|
static message(message) {
|
|
597
623
|
this.stackTrace = this.traceError(
|
|
598
|
-
|
|
599
|
-
|
|
624
|
+
import_opticore_translator2.TranslationLoader.t("processGotMsg", import_opticore_translator2.CLocal, { message }),
|
|
625
|
+
import_opticore_translator2.TranslationLoader.t("msgException", import_opticore_translator2.CLocal, { message }),
|
|
600
626
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
601
627
|
);
|
|
602
628
|
this.logger.error(
|
|
@@ -615,8 +641,8 @@ var ServerListenEventError = class {
|
|
|
615
641
|
*/
|
|
616
642
|
static multipleResolves(type, promise, reason) {
|
|
617
643
|
this.stackTrace = this.traceError(
|
|
618
|
-
|
|
619
|
-
|
|
644
|
+
import_opticore_translator2.TranslationLoader.t("promiseReason", import_opticore_translator2.CLocal, { promise, reason }),
|
|
645
|
+
import_opticore_translator2.TranslationLoader.t("multipleResolvesDetected", import_opticore_translator2.CLocal, { type, promise, reason }),
|
|
620
646
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
621
647
|
);
|
|
622
648
|
this.logger.error(
|
|
@@ -631,7 +657,7 @@ var ServerListenEventError = class {
|
|
|
631
657
|
*
|
|
632
658
|
*/
|
|
633
659
|
static processInterrupted() {
|
|
634
|
-
this.logger.success(
|
|
660
|
+
this.logger.success(import_opticore_translator2.TranslationLoader.t("okSuccess", import_opticore_translator2.CLocal), import_opticore_translator2.TranslationLoader.t("serverWebStopped", import_opticore_translator2.CLocal));
|
|
635
661
|
import_process.default.exit(0);
|
|
636
662
|
}
|
|
637
663
|
/**
|
|
@@ -640,7 +666,7 @@ var ServerListenEventError = class {
|
|
|
640
666
|
*/
|
|
641
667
|
static sigtermSignalReceived(signal) {
|
|
642
668
|
this.stackTrace = this.traceError(
|
|
643
|
-
|
|
669
|
+
import_opticore_translator2.TranslationLoader.t("processPIDReceivedSignal", import_opticore_translator2.CLocal, { signal: signal.toString() }),
|
|
644
670
|
"SIGTERM",
|
|
645
671
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
646
672
|
);
|
|
@@ -657,15 +683,15 @@ var ServerListenEventError = class {
|
|
|
657
683
|
*
|
|
658
684
|
*/
|
|
659
685
|
static serverClosing() {
|
|
660
|
-
console.log(`${import_ansi_colors.default.bgCyanBright(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` INFO `)}`)}`)} ${
|
|
661
|
-
console.log(` ${
|
|
686
|
+
console.log(`${import_ansi_colors.default.bgCyanBright(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` INFO `)}`)}`)} ${import_opticore_translator2.TranslationLoader.t("allProcessStopped", import_opticore_translator2.CLocal)}`);
|
|
687
|
+
console.log(` ${import_opticore_translator2.TranslationLoader.t("serverClosed", import_opticore_translator2.CLocal)}`);
|
|
662
688
|
import_process.default.exit();
|
|
663
689
|
}
|
|
664
690
|
/**
|
|
665
691
|
*
|
|
666
692
|
*/
|
|
667
693
|
static dropNewConnection() {
|
|
668
|
-
console.log(`${import_ansi_colors.default.cyan(`\u24D8`)} ${import_ansi_colors.default.bgCyan(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` ${
|
|
694
|
+
console.log(`${import_ansi_colors.default.cyan(`\u24D8`)} ${import_ansi_colors.default.bgCyan(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` ${import_opticore_translator2.TranslationLoader.t("serverMaxCon", import_opticore_translator2.CLocal)} `)}`)} `)} ${dateTimeFormatted} | ${import_ansi_colors.default.bgCyan(`${import_ansi_colors.default.white(` Info `)}`)} ${import_opticore_translator2.TranslationLoader.t("serverDroppedCon", import_opticore_translator2.CLocal)}`);
|
|
669
695
|
}
|
|
670
696
|
/**
|
|
671
697
|
*
|
|
@@ -679,24 +705,24 @@ var ServerListenEventError = class {
|
|
|
679
705
|
if (err) {
|
|
680
706
|
errorEmitter.emit(CEventNameError.error, err);
|
|
681
707
|
if (typeof res.status === "function") {
|
|
682
|
-
res.status(500).send(
|
|
708
|
+
res.status(500).send(import_opticore_translator2.TranslationLoader.t("internalServerError", import_opticore_translator2.CLocal, { err }));
|
|
683
709
|
} else {
|
|
684
710
|
this.logger.error(
|
|
685
|
-
|
|
711
|
+
import_opticore_translator2.TranslationLoader.t("resStatusNotFunc", import_opticore_translator2.CLocal, { err }),
|
|
686
712
|
"response status",
|
|
687
|
-
|
|
713
|
+
import_opticore_translator2.TranslationLoader.t("respndNotFunc", import_opticore_translator2.CLocal, { err }),
|
|
688
714
|
err.stack,
|
|
689
715
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
690
716
|
);
|
|
691
717
|
}
|
|
692
718
|
this.stackTrace = this.traceError(
|
|
693
719
|
err.message,
|
|
694
|
-
|
|
720
|
+
import_opticore_translator2.TranslationLoader.t("expressError", import_opticore_translator2.CLocal, { err }),
|
|
695
721
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
696
722
|
);
|
|
697
723
|
this.logger.error(
|
|
698
724
|
this.stackTrace.message,
|
|
699
|
-
|
|
725
|
+
import_opticore_translator2.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator2.CLocal, { err }),
|
|
700
726
|
this.stackTrace.name,
|
|
701
727
|
this.stackTrace.stack,
|
|
702
728
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -709,15 +735,6 @@ var ServerListenEventError = class {
|
|
|
709
735
|
return new StackTraceError(props, name, status12, true);
|
|
710
736
|
}
|
|
711
737
|
};
|
|
712
|
-
ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
713
|
-
|
|
714
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
715
|
-
var import_path = __toESM(require("path"), 1);
|
|
716
|
-
var import_opticore_translator2 = require("opticore-translator");
|
|
717
|
-
var import_opticore_env_access2 = require("opticore-env-access");
|
|
718
|
-
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
719
|
-
import_opticore_translator2.TranslationLoader.loadTranslations(import_path.default.join("src", "shared", "translations"), import_opticore_env_access2.getEnvVariable.defaultLocal);
|
|
720
|
-
};
|
|
721
738
|
// Annotate the CommonJS export names for ESM import in node:
|
|
722
739
|
0 && (module.exports = {
|
|
723
740
|
CErrorName,
|
|
@@ -734,6 +751,5 @@ var translateCatchExceptionErrorLanguageLoader = () => {
|
|
|
734
751
|
StackTraceSyntaxError,
|
|
735
752
|
StackTraceSystemError,
|
|
736
753
|
StackTraceTypeError,
|
|
737
|
-
StackTraceURIError
|
|
738
|
-
translateCatchExceptionErrorLanguageLoader
|
|
754
|
+
StackTraceURIError
|
|
739
755
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -130,6 +130,7 @@ declare class StackTraceURIError extends StackTraceError {
|
|
|
130
130
|
declare class ServerListenEventError {
|
|
131
131
|
private static logger;
|
|
132
132
|
private static stackTrace;
|
|
133
|
+
static __init(): typeof ServerListenEventError;
|
|
133
134
|
/**
|
|
134
135
|
*
|
|
135
136
|
*/
|
|
@@ -233,6 +234,4 @@ declare class ServerListenEventError {
|
|
|
233
234
|
private static traceError;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
|
237
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ declare class StackTraceURIError extends StackTraceError {
|
|
|
130
130
|
declare class ServerListenEventError {
|
|
131
131
|
private static logger;
|
|
132
132
|
private static stackTrace;
|
|
133
|
+
static __init(): typeof ServerListenEventError;
|
|
133
134
|
/**
|
|
134
135
|
*
|
|
135
136
|
*/
|
|
@@ -233,6 +234,4 @@ declare class ServerListenEventError {
|
|
|
233
234
|
private static traceError;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
|
237
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError };
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,9 @@ var CEventNameError = {
|
|
|
41
41
|
|
|
42
42
|
// src/core/errors/base/stackTraceError.ts
|
|
43
43
|
var StackTraceError = class extends Error {
|
|
44
|
+
name;
|
|
45
|
+
httpCode;
|
|
46
|
+
isOperational;
|
|
44
47
|
/**
|
|
45
48
|
*
|
|
46
49
|
* @param props
|
|
@@ -145,27 +148,47 @@ import colors from "ansi-colors";
|
|
|
145
148
|
import chalk from "chalk";
|
|
146
149
|
import { LoggerCore } from "opticore-logger";
|
|
147
150
|
import { HttpStatusCode as status11 } from "opticore-http-response";
|
|
148
|
-
import { CLocal, TranslationLoader } from "opticore-translator";
|
|
151
|
+
import { CLocal, TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
149
152
|
|
|
150
153
|
// src/utils/dateTimeFormatted.utils.ts
|
|
151
154
|
var dateTimeFormatted = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
152
155
|
|
|
153
156
|
// src/core/errors/events/serverListen.event.error.ts
|
|
157
|
+
import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
|
|
158
|
+
|
|
159
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
160
|
+
import path from "path";
|
|
161
|
+
import { TranslationLoader } from "opticore-translator";
|
|
154
162
|
import { getEnvVariable } from "opticore-env-access";
|
|
163
|
+
import { fileURLToPath } from "url";
|
|
164
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
165
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
166
|
+
const __dirname2 = path.dirname(__filename2);
|
|
167
|
+
const translateMsgJsonFilePath = path.join(__dirname2, "../../../", "utils", "translations");
|
|
168
|
+
TranslationLoader.loadTranslations(translateMsgJsonFilePath, getEnvVariable.defaultLocal);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/core/errors/events/serverListen.event.error.ts
|
|
155
172
|
var ServerListenEventError = class {
|
|
173
|
+
static logger = new LoggerCore();
|
|
174
|
+
static stackTrace;
|
|
175
|
+
static __init() {
|
|
176
|
+
translateCatchExceptionErrorLanguageLoader();
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
156
179
|
/**
|
|
157
180
|
*
|
|
158
181
|
*/
|
|
159
182
|
static hostPortUndefined() {
|
|
160
183
|
this.stackTrace = this.traceError(
|
|
161
|
-
|
|
162
|
-
|
|
184
|
+
TranslationLoader2.t("errorHostUrl", CLocal),
|
|
185
|
+
TranslationLoader2.t("listening", CLocal),
|
|
163
186
|
status11.BAD_REQUEST
|
|
164
187
|
);
|
|
165
188
|
this.logger.error(
|
|
166
189
|
this.stackTrace.message,
|
|
167
|
-
|
|
168
|
-
|
|
190
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
191
|
+
TranslationLoader2.t("badPort", CLocal, { badPort: getEnvVariable2.appPort }),
|
|
169
192
|
this.stackTrace.stack,
|
|
170
193
|
status11.BAD_REQUEST
|
|
171
194
|
);
|
|
@@ -176,14 +199,14 @@ var ServerListenEventError = class {
|
|
|
176
199
|
*/
|
|
177
200
|
static hostUndefined() {
|
|
178
201
|
this.stackTrace = this.traceError(
|
|
179
|
-
|
|
180
|
-
|
|
202
|
+
TranslationLoader2.t("badHost", CLocal, { badHost: getEnvVariable2.appHost }),
|
|
203
|
+
TranslationLoader2.t("listening", CLocal),
|
|
181
204
|
status11.BAD_REQUEST
|
|
182
205
|
);
|
|
183
206
|
this.logger.error(
|
|
184
207
|
this.stackTrace.message,
|
|
185
|
-
|
|
186
|
-
|
|
208
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
209
|
+
TranslationLoader2.t("badHost", CLocal),
|
|
187
210
|
this.stackTrace.stack,
|
|
188
211
|
status11.BAD_REQUEST
|
|
189
212
|
);
|
|
@@ -194,14 +217,14 @@ var ServerListenEventError = class {
|
|
|
194
217
|
*/
|
|
195
218
|
static portUndefined() {
|
|
196
219
|
this.stackTrace = this.traceError(
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
TranslationLoader2.t("badPort", CLocal),
|
|
221
|
+
TranslationLoader2.t("listening", CLocal),
|
|
199
222
|
status11.BAD_REQUEST
|
|
200
223
|
);
|
|
201
224
|
this.logger.error(
|
|
202
225
|
this.stackTrace.message,
|
|
203
|
-
|
|
204
|
-
|
|
226
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
227
|
+
TranslationLoader2.t("badHost", CLocal),
|
|
205
228
|
this.stackTrace.stack,
|
|
206
229
|
status11.BAD_REQUEST
|
|
207
230
|
);
|
|
@@ -213,9 +236,9 @@ var ServerListenEventError = class {
|
|
|
213
236
|
*/
|
|
214
237
|
static onEventError(err) {
|
|
215
238
|
this.logger.error(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
239
|
+
TranslationLoader2.t(err.message, CLocal),
|
|
240
|
+
TranslationLoader2.t("serverStart", CLocal),
|
|
241
|
+
TranslationLoader2.t("serverStartError", CLocal, { err }),
|
|
219
242
|
err.stack,
|
|
220
243
|
status11.SERVICE_UNAVAILABLE
|
|
221
244
|
);
|
|
@@ -244,14 +267,14 @@ var ServerListenEventError = class {
|
|
|
244
267
|
*/
|
|
245
268
|
static processBeforeExit(code) {
|
|
246
269
|
this.stackTrace = this.traceError(
|
|
247
|
-
|
|
248
|
-
|
|
270
|
+
TranslationLoader2.t("processExitCode", CLocal, { processExitCode: code }),
|
|
271
|
+
TranslationLoader2.t("beforeExit", CLocal),
|
|
249
272
|
status11.SERVICE_UNAVAILABLE
|
|
250
273
|
);
|
|
251
274
|
this.logger.error(
|
|
252
275
|
this.stackTrace.message,
|
|
253
|
-
|
|
254
|
-
|
|
276
|
+
TranslationLoader2.t("beforeExit", CLocal),
|
|
277
|
+
TranslationLoader2.t("processBeforeExit", CLocal),
|
|
255
278
|
this.stackTrace.stack,
|
|
256
279
|
status11.SERVICE_UNAVAILABLE
|
|
257
280
|
);
|
|
@@ -262,14 +285,14 @@ var ServerListenEventError = class {
|
|
|
262
285
|
*/
|
|
263
286
|
static processDisconnected() {
|
|
264
287
|
this.stackTrace = this.traceError(
|
|
265
|
-
|
|
266
|
-
|
|
288
|
+
TranslationLoader2.t("childProcessDiscon", CLocal),
|
|
289
|
+
TranslationLoader2.t("processDiscon", CLocal),
|
|
267
290
|
status11.SERVICE_UNAVAILABLE
|
|
268
291
|
);
|
|
269
292
|
this.logger.error(
|
|
270
293
|
this.stackTrace.message,
|
|
271
|
-
|
|
272
|
-
|
|
294
|
+
TranslationLoader2.t("disconnected"),
|
|
295
|
+
TranslationLoader2.t("processDiscon"),
|
|
273
296
|
this.stackTrace.stack,
|
|
274
297
|
status11.SERVICE_UNAVAILABLE
|
|
275
298
|
);
|
|
@@ -283,25 +306,25 @@ var ServerListenEventError = class {
|
|
|
283
306
|
switch (code) {
|
|
284
307
|
case 0:
|
|
285
308
|
this.logger.success(
|
|
286
|
-
|
|
287
|
-
|
|
309
|
+
TranslationLoader2.t("completed", CLocal, { code }),
|
|
310
|
+
TranslationLoader2.t("finishingProcessWell", CLocal, { code })
|
|
288
311
|
);
|
|
289
312
|
console.log("");
|
|
290
313
|
const paddingLength = 35;
|
|
291
314
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
292
315
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
293
|
-
console.log(`${colors.bgGreen(` ${
|
|
316
|
+
console.log(`${colors.bgGreen(` ${TranslationLoader2.t("serverStopped", CLocal)} `)}`);
|
|
294
317
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
295
318
|
break;
|
|
296
319
|
case 1:
|
|
297
320
|
this.stackTrace = this.traceError(
|
|
298
|
-
|
|
299
|
-
|
|
321
|
+
TranslationLoader2.t("somethingWentWrong", CLocal),
|
|
322
|
+
TranslationLoader2.t("genErrors", CLocal),
|
|
300
323
|
status11.SERVICE_UNAVAILABLE
|
|
301
324
|
);
|
|
302
325
|
this.logger.error(
|
|
303
326
|
this.stackTrace.message,
|
|
304
|
-
|
|
327
|
+
TranslationLoader2.t("exited", CLocal),
|
|
305
328
|
"General Errors",
|
|
306
329
|
this.stackTrace.stack,
|
|
307
330
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -309,27 +332,27 @@ var ServerListenEventError = class {
|
|
|
309
332
|
break;
|
|
310
333
|
case 2:
|
|
311
334
|
this.stackTrace = this.traceError(
|
|
312
|
-
|
|
313
|
-
|
|
335
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
336
|
+
TranslationLoader2.t("misuseShell", CLocal),
|
|
314
337
|
status11.SERVICE_UNAVAILABLE
|
|
315
338
|
);
|
|
316
339
|
this.logger.error(
|
|
317
340
|
this.stackTrace.message,
|
|
318
|
-
|
|
319
|
-
|
|
341
|
+
TranslationLoader2.t("exited", CLocal),
|
|
342
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
320
343
|
this.stackTrace.stack,
|
|
321
344
|
status11.SERVICE_UNAVAILABLE
|
|
322
345
|
);
|
|
323
346
|
break;
|
|
324
347
|
case 126:
|
|
325
348
|
this.stackTrace = this.traceError(
|
|
326
|
-
|
|
327
|
-
|
|
349
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
350
|
+
TranslationLoader2.t("cmdNotExecutable", CLocal),
|
|
328
351
|
status11.SERVICE_UNAVAILABLE
|
|
329
352
|
);
|
|
330
353
|
this.logger.error(
|
|
331
354
|
this.stackTrace.message,
|
|
332
|
-
|
|
355
|
+
TranslationLoader2.t("exited", CLocal),
|
|
333
356
|
this.stackTrace.name,
|
|
334
357
|
this.stackTrace.stack,
|
|
335
358
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -337,13 +360,13 @@ var ServerListenEventError = class {
|
|
|
337
360
|
break;
|
|
338
361
|
case 127:
|
|
339
362
|
this.stackTrace = this.traceError(
|
|
340
|
-
|
|
341
|
-
|
|
363
|
+
TranslationLoader2.t("cmdNotFound", CLocal),
|
|
364
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", CLocal),
|
|
342
365
|
status11.SERVICE_UNAVAILABLE
|
|
343
366
|
);
|
|
344
367
|
this.logger.error(
|
|
345
368
|
this.stackTrace.message,
|
|
346
|
-
|
|
369
|
+
TranslationLoader2.t("exited", CLocal),
|
|
347
370
|
this.stackTrace.name,
|
|
348
371
|
this.stackTrace.stack,
|
|
349
372
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -351,13 +374,13 @@ var ServerListenEventError = class {
|
|
|
351
374
|
break;
|
|
352
375
|
case 128:
|
|
353
376
|
this.stackTrace = this.traceError(
|
|
354
|
-
|
|
355
|
-
|
|
377
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", CLocal),
|
|
378
|
+
TranslationLoader2.t("argInvalid", CLocal),
|
|
356
379
|
status11.SERVICE_UNAVAILABLE
|
|
357
380
|
);
|
|
358
381
|
this.logger.error(
|
|
359
382
|
this.stackTrace.message,
|
|
360
|
-
|
|
383
|
+
TranslationLoader2.t("exited", CLocal),
|
|
361
384
|
this.stackTrace.name,
|
|
362
385
|
this.stackTrace.stack,
|
|
363
386
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -365,13 +388,13 @@ var ServerListenEventError = class {
|
|
|
365
388
|
break;
|
|
366
389
|
case 130:
|
|
367
390
|
this.stackTrace = this.traceError(
|
|
368
|
-
|
|
369
|
-
|
|
391
|
+
TranslationLoader2.t("scriptEndedManuallyByCtrlC", CLocal),
|
|
392
|
+
TranslationLoader2.t("scriptEnded", CLocal),
|
|
370
393
|
status11.SERVICE_UNAVAILABLE
|
|
371
394
|
);
|
|
372
395
|
this.logger.error(
|
|
373
396
|
this.stackTrace.message,
|
|
374
|
-
|
|
397
|
+
TranslationLoader2.t("exited", CLocal),
|
|
375
398
|
this.stackTrace.name,
|
|
376
399
|
this.stackTrace.stack,
|
|
377
400
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -379,13 +402,13 @@ var ServerListenEventError = class {
|
|
|
379
402
|
break;
|
|
380
403
|
case 137:
|
|
381
404
|
this.stackTrace = this.traceError(
|
|
382
|
-
|
|
405
|
+
TranslationLoader2.t("processEndedBySIGKILL", CLocal),
|
|
383
406
|
"SIGKILL",
|
|
384
407
|
status11.SERVICE_UNAVAILABLE
|
|
385
408
|
);
|
|
386
409
|
this.logger.error(
|
|
387
410
|
this.stackTrace.message,
|
|
388
|
-
|
|
411
|
+
TranslationLoader2.t("exited", CLocal),
|
|
389
412
|
this.stackTrace.name,
|
|
390
413
|
this.stackTrace.stack,
|
|
391
414
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -393,13 +416,13 @@ var ServerListenEventError = class {
|
|
|
393
416
|
break;
|
|
394
417
|
case 139:
|
|
395
418
|
this.stackTrace = this.traceError(
|
|
396
|
-
|
|
397
|
-
|
|
419
|
+
TranslationLoader2.t("accessProcessIllegally", CLocal),
|
|
420
|
+
TranslationLoader2.t("defaultSegment", CLocal),
|
|
398
421
|
status11.SERVICE_UNAVAILABLE
|
|
399
422
|
);
|
|
400
423
|
this.logger.error(
|
|
401
424
|
this.stackTrace.message,
|
|
402
|
-
|
|
425
|
+
TranslationLoader2.t("exited", CLocal),
|
|
403
426
|
this.stackTrace.name,
|
|
404
427
|
this.stackTrace.stack,
|
|
405
428
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -407,13 +430,13 @@ var ServerListenEventError = class {
|
|
|
407
430
|
break;
|
|
408
431
|
case 143:
|
|
409
432
|
this.stackTrace = this.traceError(
|
|
410
|
-
|
|
411
|
-
|
|
433
|
+
TranslationLoader2.t("processReceivedSigtermSignal", CLocal),
|
|
434
|
+
TranslationLoader2.t("processReceived", CLocal),
|
|
412
435
|
status11.SERVICE_UNAVAILABLE
|
|
413
436
|
);
|
|
414
437
|
this.logger.error(
|
|
415
438
|
this.stackTrace.message,
|
|
416
|
-
|
|
439
|
+
TranslationLoader2.t("exited", CLocal),
|
|
417
440
|
this.stackTrace.name,
|
|
418
441
|
this.stackTrace.stack,
|
|
419
442
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -421,13 +444,13 @@ var ServerListenEventError = class {
|
|
|
421
444
|
break;
|
|
422
445
|
case 255:
|
|
423
446
|
this.stackTrace = this.traceError(
|
|
424
|
-
|
|
425
|
-
|
|
447
|
+
TranslationLoader2.t("exitCode", CLocal),
|
|
448
|
+
TranslationLoader2.t("outRange", CLocal),
|
|
426
449
|
status11.SERVICE_UNAVAILABLE
|
|
427
450
|
);
|
|
428
451
|
this.logger.error(
|
|
429
452
|
this.stackTrace.message,
|
|
430
|
-
|
|
453
|
+
TranslationLoader2.t("exited", CLocal),
|
|
431
454
|
this.stackTrace.name,
|
|
432
455
|
this.stackTrace.stack,
|
|
433
456
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -435,13 +458,13 @@ var ServerListenEventError = class {
|
|
|
435
458
|
break;
|
|
436
459
|
default:
|
|
437
460
|
this.stackTrace = this.traceError(
|
|
438
|
-
|
|
439
|
-
|
|
461
|
+
TranslationLoader2.t("errorOccurring", CLocal),
|
|
462
|
+
TranslationLoader2.t("errors", CLocal),
|
|
440
463
|
status11.SERVICE_UNAVAILABLE
|
|
441
464
|
);
|
|
442
465
|
this.logger.error(
|
|
443
466
|
this.stackTrace.message,
|
|
444
|
-
|
|
467
|
+
TranslationLoader2.t("exited", CLocal),
|
|
445
468
|
this.stackTrace.name,
|
|
446
469
|
this.stackTrace.stack,
|
|
447
470
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -456,8 +479,8 @@ var ServerListenEventError = class {
|
|
|
456
479
|
static promiseRejectionHandled(promise) {
|
|
457
480
|
try {
|
|
458
481
|
this.stackTrace = this.traceError(
|
|
459
|
-
|
|
460
|
-
|
|
482
|
+
TranslationLoader2.t("promise", CLocal, { promise }),
|
|
483
|
+
TranslationLoader2.t("rejectionPromise", CLocal, { promise }),
|
|
461
484
|
status11.SERVICE_UNAVAILABLE
|
|
462
485
|
);
|
|
463
486
|
this.logger.error(
|
|
@@ -479,8 +502,8 @@ var ServerListenEventError = class {
|
|
|
479
502
|
console.log("");
|
|
480
503
|
} else {
|
|
481
504
|
this.stackTrace = this.traceError(
|
|
482
|
-
|
|
483
|
-
|
|
505
|
+
TranslationLoader2.t(error.message),
|
|
506
|
+
TranslationLoader2.t("uncaughtExceptionHandled", CLocal),
|
|
484
507
|
status11.SERVICE_UNAVAILABLE
|
|
485
508
|
);
|
|
486
509
|
this.logger.error(
|
|
@@ -508,8 +531,8 @@ var ServerListenEventError = class {
|
|
|
508
531
|
*/
|
|
509
532
|
static unhandledRejection(reason, promise) {
|
|
510
533
|
this.stackTrace = this.traceError(
|
|
511
|
-
|
|
512
|
-
|
|
534
|
+
TranslationLoader2.t("unhandledRejectionAtPromise", CLocal, { promise, reason }),
|
|
535
|
+
TranslationLoader2.t("unhandledRejection", CLocal, { promise, reason }),
|
|
513
536
|
status11.SERVICE_UNAVAILABLE
|
|
514
537
|
);
|
|
515
538
|
this.logger.error(
|
|
@@ -526,13 +549,13 @@ var ServerListenEventError = class {
|
|
|
526
549
|
*/
|
|
527
550
|
static warning(warning) {
|
|
528
551
|
this.stackTrace = this.traceError(
|
|
529
|
-
|
|
552
|
+
TranslationLoader2.t(warning.message, CLocal),
|
|
530
553
|
"warning",
|
|
531
554
|
status11.SERVICE_UNAVAILABLE
|
|
532
555
|
);
|
|
533
556
|
this.logger.error(
|
|
534
557
|
this.stackTrace.message,
|
|
535
|
-
|
|
558
|
+
TranslationLoader2.t("warning", CLocal, { warning }),
|
|
536
559
|
this.stackTrace.name,
|
|
537
560
|
this.stackTrace.stack,
|
|
538
561
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -544,8 +567,8 @@ var ServerListenEventError = class {
|
|
|
544
567
|
*/
|
|
545
568
|
static message(message) {
|
|
546
569
|
this.stackTrace = this.traceError(
|
|
547
|
-
|
|
548
|
-
|
|
570
|
+
TranslationLoader2.t("processGotMsg", CLocal, { message }),
|
|
571
|
+
TranslationLoader2.t("msgException", CLocal, { message }),
|
|
549
572
|
status11.SERVICE_UNAVAILABLE
|
|
550
573
|
);
|
|
551
574
|
this.logger.error(
|
|
@@ -564,8 +587,8 @@ var ServerListenEventError = class {
|
|
|
564
587
|
*/
|
|
565
588
|
static multipleResolves(type, promise, reason) {
|
|
566
589
|
this.stackTrace = this.traceError(
|
|
567
|
-
|
|
568
|
-
|
|
590
|
+
TranslationLoader2.t("promiseReason", CLocal, { promise, reason }),
|
|
591
|
+
TranslationLoader2.t("multipleResolvesDetected", CLocal, { type, promise, reason }),
|
|
569
592
|
status11.SERVICE_UNAVAILABLE
|
|
570
593
|
);
|
|
571
594
|
this.logger.error(
|
|
@@ -580,7 +603,7 @@ var ServerListenEventError = class {
|
|
|
580
603
|
*
|
|
581
604
|
*/
|
|
582
605
|
static processInterrupted() {
|
|
583
|
-
this.logger.success(
|
|
606
|
+
this.logger.success(TranslationLoader2.t("okSuccess", CLocal), TranslationLoader2.t("serverWebStopped", CLocal));
|
|
584
607
|
process.exit(0);
|
|
585
608
|
}
|
|
586
609
|
/**
|
|
@@ -589,7 +612,7 @@ var ServerListenEventError = class {
|
|
|
589
612
|
*/
|
|
590
613
|
static sigtermSignalReceived(signal) {
|
|
591
614
|
this.stackTrace = this.traceError(
|
|
592
|
-
|
|
615
|
+
TranslationLoader2.t("processPIDReceivedSignal", CLocal, { signal: signal.toString() }),
|
|
593
616
|
"SIGTERM",
|
|
594
617
|
status11.NOT_ACCEPTABLE
|
|
595
618
|
);
|
|
@@ -606,15 +629,15 @@ var ServerListenEventError = class {
|
|
|
606
629
|
*
|
|
607
630
|
*/
|
|
608
631
|
static serverClosing() {
|
|
609
|
-
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${
|
|
610
|
-
console.log(` ${
|
|
632
|
+
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${TranslationLoader2.t("allProcessStopped", CLocal)}`);
|
|
633
|
+
console.log(` ${TranslationLoader2.t("serverClosed", CLocal)}`);
|
|
611
634
|
process.exit();
|
|
612
635
|
}
|
|
613
636
|
/**
|
|
614
637
|
*
|
|
615
638
|
*/
|
|
616
639
|
static dropNewConnection() {
|
|
617
|
-
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${
|
|
640
|
+
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${TranslationLoader2.t("serverMaxCon", CLocal)} `)}`)} `)} ${dateTimeFormatted} | ${colors.bgCyan(`${colors.white(` Info `)}`)} ${TranslationLoader2.t("serverDroppedCon", CLocal)}`);
|
|
618
641
|
}
|
|
619
642
|
/**
|
|
620
643
|
*
|
|
@@ -628,24 +651,24 @@ var ServerListenEventError = class {
|
|
|
628
651
|
if (err) {
|
|
629
652
|
errorEmitter.emit(CEventNameError.error, err);
|
|
630
653
|
if (typeof res.status === "function") {
|
|
631
|
-
res.status(500).send(
|
|
654
|
+
res.status(500).send(TranslationLoader2.t("internalServerError", CLocal, { err }));
|
|
632
655
|
} else {
|
|
633
656
|
this.logger.error(
|
|
634
|
-
|
|
657
|
+
TranslationLoader2.t("resStatusNotFunc", CLocal, { err }),
|
|
635
658
|
"response status",
|
|
636
|
-
|
|
659
|
+
TranslationLoader2.t("respndNotFunc", CLocal, { err }),
|
|
637
660
|
err.stack,
|
|
638
661
|
status11.NOT_ACCEPTABLE
|
|
639
662
|
);
|
|
640
663
|
}
|
|
641
664
|
this.stackTrace = this.traceError(
|
|
642
665
|
err.message,
|
|
643
|
-
|
|
666
|
+
TranslationLoader2.t("expressError", CLocal, { err }),
|
|
644
667
|
status11.NOT_ACCEPTABLE
|
|
645
668
|
);
|
|
646
669
|
this.logger.error(
|
|
647
670
|
this.stackTrace.message,
|
|
648
|
-
|
|
671
|
+
TranslationLoader2.t("expressErrorHandlingMiddleware", CLocal, { err }),
|
|
649
672
|
this.stackTrace.name,
|
|
650
673
|
this.stackTrace.stack,
|
|
651
674
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -658,15 +681,6 @@ var ServerListenEventError = class {
|
|
|
658
681
|
return new StackTraceError(props, name, status12, true);
|
|
659
682
|
}
|
|
660
683
|
};
|
|
661
|
-
ServerListenEventError.logger = new LoggerCore();
|
|
662
|
-
|
|
663
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
664
|
-
import path from "path";
|
|
665
|
-
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
666
|
-
import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
|
|
667
|
-
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
668
|
-
TranslationLoader2.loadTranslations(path.join("src", "shared", "translations"), getEnvVariable2.defaultLocal);
|
|
669
|
-
};
|
|
670
684
|
export {
|
|
671
685
|
CErrorName,
|
|
672
686
|
CEvent,
|
|
@@ -682,6 +696,5 @@ export {
|
|
|
682
696
|
StackTraceSyntaxError,
|
|
683
697
|
StackTraceSystemError,
|
|
684
698
|
StackTraceTypeError,
|
|
685
|
-
StackTraceURIError
|
|
686
|
-
translateCatchExceptionErrorLanguageLoader
|
|
699
|
+
StackTraceURIError
|
|
687
700
|
};
|
package/example/index.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import {CLocal, TranslationLoader} from "opticore-translator";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import {ServerListenEventError} from "../src";
|
|
4
|
+
import process from "process";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
console.log(
|
|
6
|
+
console.log(TranslationLoader.t("rejectionPromise", 'en', { promise: "wd digital" }));
|
|
7
|
+
//console.log("__init is : ", ServerListenEventError.__init());
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
// Convertir l'URL du fichier en chemin de fichier
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
console.log("__filename is : ", __filename);
|
|
14
|
+
|
|
15
|
+
// Obtenir le répertoire du fichier
|
|
16
|
+
(() => {
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
const server = ServerListenEventError.__init();
|
|
19
|
+
server.hostPortUndefined();
|
|
20
|
+
})()
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"noImplicitAny": true,
|
|
5
5
|
"esModuleInterop": true,
|
|
6
6
|
"strictNullChecks": true,
|
|
7
|
-
"module": "
|
|
7
|
+
"module": "ES2022",
|
|
8
8
|
"pretty": true,
|
|
9
|
-
"target": "
|
|
9
|
+
"target": "es2022",
|
|
10
10
|
"moduleResolution": "node",
|
|
11
11
|
"declaration": true,
|
|
12
12
|
"isolatedModules": true,
|