@onlineapps/conn-infra-error-handler 1.0.1 → 1.0.2
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/package.json +4 -3
- package/src/config.js +33 -0
- package/src/defaults.js +17 -0
- package/src/index.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-infra-error-handler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Unified error handling with retry strategies, circuit breaker, and compensation patterns",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"author": "OA Drive Team",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@onlineapps/conn-base-monitoring": "
|
|
23
|
-
"@onlineapps/error-handler-core": "1.1.
|
|
22
|
+
"@onlineapps/conn-base-monitoring": "1.0.2",
|
|
23
|
+
"@onlineapps/error-handler-core": "1.1.1",
|
|
24
|
+
"@onlineapps/runtime-config": "1.0.2"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"jest": "^29.7.0"
|
package/src/config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime configuration schema for @onlineapps/conn-infra-error-handler.
|
|
5
|
+
*
|
|
6
|
+
* Uses @onlineapps/runtime-config for unified priority:
|
|
7
|
+
* 1. Explicit config
|
|
8
|
+
* 2. Environment variable (if applicable)
|
|
9
|
+
* 3. Owner defaults (from ./defaults.js)
|
|
10
|
+
*
|
|
11
|
+
* NOTE: Core error handling defaults belong to @onlineapps/error-handler-core.
|
|
12
|
+
* This config only covers wrapper placeholders.
|
|
13
|
+
*
|
|
14
|
+
* @module @onlineapps/conn-infra-error-handler/config
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { createRuntimeConfig } = require('@onlineapps/runtime-config');
|
|
18
|
+
const DEFAULTS = require('./defaults');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Runtime config schema for ErrorHandlerConnector
|
|
22
|
+
*/
|
|
23
|
+
const runtimeCfg = createRuntimeConfig({
|
|
24
|
+
defaults: DEFAULTS,
|
|
25
|
+
schema: {
|
|
26
|
+
unknownQueueName: { defaultKey: 'unknownQueueName' },
|
|
27
|
+
unknownErrorCode: { defaultKey: 'unknownErrorCode' },
|
|
28
|
+
version: { defaultKey: 'version' },
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
module.exports = runtimeCfg;
|
|
33
|
+
|
package/src/defaults.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module-owned defaults for @onlineapps/conn-infra-error-handler.
|
|
5
|
+
*
|
|
6
|
+
* Ownership rule:
|
|
7
|
+
* - Defaults in this file belong to this connector wrapper.
|
|
8
|
+
* - Core behavior defaults belong to @onlineapps/error-handler-core.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
unknownQueueName: 'unknown',
|
|
13
|
+
unknownErrorCode: 'UNKNOWN_ERROR',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
const { ErrorHandlerCore } = require('@onlineapps/error-handler-core');
|
|
16
16
|
const { ErrorTypes, ErrorCodes } = require('@onlineapps/error-handler-core');
|
|
17
|
+
const runtimeCfg = require('./config');
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Error handling connector for business services
|
|
@@ -337,7 +338,7 @@ class ErrorHandlerConnector {
|
|
|
337
338
|
async routeToDLQ(mqClient, message, error) {
|
|
338
339
|
const errorType = this.classifyError(error);
|
|
339
340
|
await this.core.dlqRouter.routeToDLQ(message, error, errorType, {
|
|
340
|
-
queue: message.queue || '
|
|
341
|
+
queue: message.queue || runtimeCfg.get('unknownQueueName')
|
|
341
342
|
});
|
|
342
343
|
}
|
|
343
344
|
|
|
@@ -356,7 +357,7 @@ class ErrorHandlerConnector {
|
|
|
356
357
|
success: false,
|
|
357
358
|
error: {
|
|
358
359
|
message: error.message,
|
|
359
|
-
code: error.code || '
|
|
360
|
+
code: error.code || runtimeCfg.get('unknownErrorCode'),
|
|
360
361
|
type: errorType,
|
|
361
362
|
retryable: this.shouldRetry(error),
|
|
362
363
|
timestamp: new Date().toISOString(),
|
|
@@ -450,4 +451,4 @@ module.exports.create = (config) => new ErrorHandlerConnector(config);
|
|
|
450
451
|
* Current version
|
|
451
452
|
* @constant {string}
|
|
452
453
|
*/
|
|
453
|
-
module.exports.VERSION =
|
|
454
|
+
module.exports.VERSION = runtimeCfg.get('version');
|