@lowdefy/errors 0.0.0-experimental-20260204101136 → 0.0.0-experimental-20260204112702
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/ConfigError.js +2 -6
- package/dist/ConfigWarning.js +1 -6
- package/dist/LowdefyError.js +1 -9
- package/dist/PluginError.js +4 -15
- package/dist/ServiceError.js +1 -5
- package/dist/build/ConfigError.js +6 -5
- package/dist/build/ConfigMessage.js +11 -12
- package/dist/build/ConfigWarning.js +3 -10
- package/dist/build/resolveConfigLocation.js +8 -6
- package/dist/client/index.js +2 -3
- package/dist/index.js +1 -2
- package/package.json +1 -1
- package/dist/UserError.js +0 -28
- package/dist/client/LowdefyError.js +0 -55
- package/dist/formatErrorMessage.js +0 -31
package/dist/ConfigError.js
CHANGED
|
@@ -31,11 +31,7 @@
|
|
|
31
31
|
* configKey: block['~k'],
|
|
32
32
|
* location: { source: 'pages/home.yaml:42', link: '/path/to/pages/home.yaml:42' }
|
|
33
33
|
* });
|
|
34
|
-
*/
|
|
35
|
-
let ConfigError = class ConfigError extends Error {
|
|
36
|
-
print() {
|
|
37
|
-
return formatErrorMessage(this);
|
|
38
|
-
}
|
|
34
|
+
*/ let ConfigError = class ConfigError extends Error {
|
|
39
35
|
/**
|
|
40
36
|
* Serializes the error for transport (e.g., client to server).
|
|
41
37
|
* @returns {Object} Serialized error data with type marker
|
|
@@ -72,7 +68,7 @@ let ConfigError = class ConfigError extends Error {
|
|
|
72
68
|
const configKey = isString ? null : messageOrParams.configKey ?? error?.configKey;
|
|
73
69
|
const location = isString ? null : messageOrParams.location;
|
|
74
70
|
const checkSlug = isString ? undefined : messageOrParams.checkSlug;
|
|
75
|
-
const received = isString ? undefined : messageOrParams.received
|
|
71
|
+
const received = isString ? undefined : messageOrParams.received;
|
|
76
72
|
const operatorLocation = isString ? null : messageOrParams.operatorLocation;
|
|
77
73
|
// Message without prefix - logger uses error.name for display
|
|
78
74
|
super(message);
|
package/dist/ConfigWarning.js
CHANGED
|
@@ -23,17 +23,12 @@
|
|
|
23
23
|
* @example
|
|
24
24
|
* const warning = new ConfigWarning({ message: 'Deprecated feature used', source: 'config.yaml:10' });
|
|
25
25
|
* console.warn(warning.message);
|
|
26
|
-
*/
|
|
27
|
-
let ConfigWarning = class ConfigWarning {
|
|
28
|
-
print() {
|
|
29
|
-
return formatErrorMessage(this);
|
|
30
|
-
}
|
|
26
|
+
*/ let ConfigWarning = class ConfigWarning {
|
|
31
27
|
/**
|
|
32
28
|
* @param {Object} params
|
|
33
29
|
* @param {string} params.message - The warning message
|
|
34
30
|
* @param {string} [params.source] - Source file:line
|
|
35
31
|
*/ constructor({ message, source }){
|
|
36
|
-
this.name = 'Config Warning';
|
|
37
32
|
// Message without prefix - logger uses class name for display
|
|
38
33
|
this.message = message;
|
|
39
34
|
this.source = source ?? null;
|
package/dist/LowdefyError.js
CHANGED
|
@@ -28,15 +28,7 @@
|
|
|
28
28
|
* console.error(err.message);
|
|
29
29
|
* console.error(err.stack);
|
|
30
30
|
* }
|
|
31
|
-
*/
|
|
32
|
-
let LowdefyError = class LowdefyError extends Error {
|
|
33
|
-
print() {
|
|
34
|
-
const message = formatErrorMessage(this);
|
|
35
|
-
if (this.stack) {
|
|
36
|
-
return `${message}\n${this.stack}`;
|
|
37
|
-
}
|
|
38
|
-
return message;
|
|
39
|
-
}
|
|
31
|
+
*/ let LowdefyError = class LowdefyError extends Error {
|
|
40
32
|
/**
|
|
41
33
|
* Serializes the error for transport (e.g., client to server).
|
|
42
34
|
* @returns {Object} Serialized error data with type marker
|
package/dist/PluginError.js
CHANGED
|
@@ -35,11 +35,7 @@
|
|
|
35
35
|
* });
|
|
36
36
|
* }
|
|
37
37
|
* // error.message = "[Plugin Error] _if requires boolean test. Received: {...} at blocks.0.properties.visible."
|
|
38
|
-
*/
|
|
39
|
-
let PluginError = class PluginError extends Error {
|
|
40
|
-
print() {
|
|
41
|
-
return formatErrorMessage(this);
|
|
42
|
-
}
|
|
38
|
+
*/ let PluginError = class PluginError extends Error {
|
|
43
39
|
/**
|
|
44
40
|
* Serializes the error for transport (e.g., client to server).
|
|
45
41
|
* @returns {Object} Serialized error data with type marker
|
|
@@ -47,7 +43,6 @@ let PluginError = class PluginError extends Error {
|
|
|
47
43
|
return {
|
|
48
44
|
'~err': 'PluginError',
|
|
49
45
|
message: this.message,
|
|
50
|
-
rawMessage: this.rawMessage,
|
|
51
46
|
pluginType: this.pluginType,
|
|
52
47
|
pluginName: this.pluginName,
|
|
53
48
|
location: this.location,
|
|
@@ -62,20 +57,14 @@ let PluginError = class PluginError extends Error {
|
|
|
62
57
|
* @param {Object} data - Serialized error data
|
|
63
58
|
* @returns {PluginError}
|
|
64
59
|
*/ static deserialize(data) {
|
|
65
|
-
// Use rawMessage if available, fallback to message
|
|
66
|
-
const messageToUse = data.rawMessage || data.message;
|
|
67
60
|
const error = new PluginError({
|
|
68
|
-
|
|
61
|
+
error: new Error(data.message),
|
|
69
62
|
pluginType: data.pluginType,
|
|
70
63
|
pluginName: data.pluginName,
|
|
71
64
|
configKey: data.configKey
|
|
72
65
|
});
|
|
73
66
|
// Set location separately to preserve it without re-formatting message
|
|
74
67
|
error.location = data.location;
|
|
75
|
-
// Preserve the formatted message if different from rawMessage
|
|
76
|
-
if (data.message && data.message !== messageToUse) {
|
|
77
|
-
error.message = data.message;
|
|
78
|
-
}
|
|
79
68
|
if (data.stack) {
|
|
80
69
|
error.stack = data.stack;
|
|
81
70
|
}
|
|
@@ -96,7 +85,7 @@ let PluginError = class PluginError extends Error {
|
|
|
96
85
|
const rawMessage = message ?? error?.message;
|
|
97
86
|
let formattedMessage = rawMessage;
|
|
98
87
|
if (location) {
|
|
99
|
-
formattedMessage
|
|
88
|
+
formattedMessage += ` at ${location}.`;
|
|
100
89
|
}
|
|
101
90
|
super(formattedMessage, {
|
|
102
91
|
cause: error
|
|
@@ -105,7 +94,7 @@ let PluginError = class PluginError extends Error {
|
|
|
105
94
|
this.pluginType = pluginType;
|
|
106
95
|
this.pluginName = pluginName;
|
|
107
96
|
this.rawMessage = rawMessage; // Original message without location
|
|
108
|
-
this.received = received
|
|
97
|
+
this.received = received;
|
|
109
98
|
this.location = location;
|
|
110
99
|
this.configKey = error?.configKey ?? configKey ?? null;
|
|
111
100
|
// Location info (set by server-side resolution)
|
package/dist/ServiceError.js
CHANGED
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
* throw new PluginError({ error, ... });
|
|
49
49
|
* }
|
|
50
50
|
* // error.message = "[Service Error] MongoDB: Connection refused. The service may be down..."
|
|
51
|
-
*/
|
|
52
|
-
let ServiceError = class ServiceError extends Error {
|
|
51
|
+
*/ let ServiceError = class ServiceError extends Error {
|
|
53
52
|
/**
|
|
54
53
|
* Checks if an error is a service error (network issues, timeouts, 5xx).
|
|
55
54
|
* @param {Error} error - The error to check
|
|
@@ -96,9 +95,6 @@ let ServiceError = class ServiceError extends Error {
|
|
|
96
95
|
}
|
|
97
96
|
return error.message;
|
|
98
97
|
}
|
|
99
|
-
print() {
|
|
100
|
-
return formatErrorMessage(this);
|
|
101
|
-
}
|
|
102
98
|
/**
|
|
103
99
|
* Serializes the error for transport (e.g., client to server).
|
|
104
100
|
* @returns {Object} Serialized error data with type marker
|
|
@@ -84,22 +84,23 @@ import ConfigMessage from './ConfigMessage.js';
|
|
|
84
84
|
this.resolved = true;
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
// Resolve location based on available info
|
|
87
|
+
// Resolve location based on available info
|
|
88
88
|
let location = null;
|
|
89
89
|
const configDir = configDirectory ?? context?.directories?.config;
|
|
90
90
|
if (configKey && context?.keyMap) {
|
|
91
|
+
// Mode 1: Use configKey -> keyMap -> refMap path (standard case after addKeys)
|
|
91
92
|
location = ConfigMessage.resolveLocation({
|
|
92
93
|
configKey,
|
|
93
94
|
context
|
|
94
95
|
});
|
|
95
|
-
}
|
|
96
|
-
|
|
96
|
+
} else if (operatorLocation && context?.refMap) {
|
|
97
|
+
// Mode 2: Use operatorLocation directly with refMap (early build stages)
|
|
97
98
|
location = ConfigMessage.resolveOperatorLocation({
|
|
98
99
|
operatorLocation,
|
|
99
100
|
context
|
|
100
101
|
});
|
|
101
|
-
}
|
|
102
|
-
|
|
102
|
+
} else if (filePath) {
|
|
103
|
+
// Mode 3: Use raw filePath/lineNumber (YAML parse errors, etc.)
|
|
103
104
|
location = ConfigMessage.resolveRawLocation({
|
|
104
105
|
filePath,
|
|
105
106
|
lineNumber: finalLineNumber,
|
|
@@ -25,8 +25,8 @@ import resolveConfigLocation from './resolveConfigLocation.js';
|
|
|
25
25
|
'link-refs': 'Invalid Link action page reference warnings',
|
|
26
26
|
'request-refs': 'Invalid Request action reference warnings',
|
|
27
27
|
'connection-refs': 'Nonexistent connection ID references',
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
types: 'All type validation (blocks, operators, actions, requests, connections)',
|
|
29
|
+
schema: 'JSON schema validation errors'
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Base class for config message utilities.
|
|
@@ -87,17 +87,16 @@ import resolveConfigLocation from './resolveConfigLocation.js';
|
|
|
87
87
|
*/ static resolveOperatorLocation({ operatorLocation, context }) {
|
|
88
88
|
if (!operatorLocation) return null;
|
|
89
89
|
const refEntry = context?.refMap?.[operatorLocation.ref];
|
|
90
|
-
|
|
91
|
-
const filePath = refEntry.path;
|
|
90
|
+
const filePath = refEntry?.path ?? 'lowdefy.yaml';
|
|
92
91
|
const lineNumber = operatorLocation.line;
|
|
93
|
-
|
|
92
|
+
const source = lineNumber ? `${filePath}:${lineNumber}` : filePath;
|
|
93
|
+
let link = null;
|
|
94
94
|
if (context?.directories?.config) {
|
|
95
|
-
|
|
95
|
+
link = path.join(context.directories.config, filePath) + (lineNumber ? `:${lineNumber}` : '');
|
|
96
96
|
}
|
|
97
|
-
const source = lineNumber ? `${resolvedPath}:${lineNumber}` : resolvedPath;
|
|
98
97
|
return {
|
|
99
98
|
source,
|
|
100
|
-
link
|
|
99
|
+
link
|
|
101
100
|
};
|
|
102
101
|
}
|
|
103
102
|
/**
|
|
@@ -109,14 +108,14 @@ import resolveConfigLocation from './resolveConfigLocation.js';
|
|
|
109
108
|
* @param {string} [params.configDirectory] - Config directory for link
|
|
110
109
|
* @returns {Object} Location object { source, link }
|
|
111
110
|
*/ static resolveRawLocation({ filePath, lineNumber, configDirectory }) {
|
|
112
|
-
|
|
111
|
+
const source = lineNumber ? `${filePath}:${lineNumber}` : filePath;
|
|
112
|
+
let link = null;
|
|
113
113
|
if (configDirectory) {
|
|
114
|
-
|
|
114
|
+
link = path.join(configDirectory, filePath) + (lineNumber ? `:${lineNumber}` : '');
|
|
115
115
|
}
|
|
116
|
-
const source = lineNumber ? `${resolvedPath}:${lineNumber}` : resolvedPath;
|
|
117
116
|
return {
|
|
118
117
|
source,
|
|
119
|
-
link
|
|
118
|
+
link
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
121
|
};
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import ConfigError from './ConfigError.js';
|
|
16
16
|
import ConfigMessage from './ConfigMessage.js';
|
|
17
|
-
import formatErrorMessage from '../formatErrorMessage.js';
|
|
18
17
|
/**
|
|
19
18
|
* Build-time configuration warning class.
|
|
20
19
|
* All formatting happens in the constructor - properties are ready for the logger.
|
|
@@ -32,9 +31,6 @@ import formatErrorMessage from '../formatErrorMessage.js';
|
|
|
32
31
|
* // Throws ConfigError in prod mode when prodError is true
|
|
33
32
|
* new ConfigWarning({ message, configKey, context, prodError: true });
|
|
34
33
|
*/ let ConfigWarning = class ConfigWarning {
|
|
35
|
-
print() {
|
|
36
|
-
return formatErrorMessage(this);
|
|
37
|
-
}
|
|
38
34
|
/**
|
|
39
35
|
* @param {Object} params
|
|
40
36
|
* @param {string} params.message - The warning message
|
|
@@ -61,7 +57,6 @@ import formatErrorMessage from '../formatErrorMessage.js';
|
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
59
|
// Store all properties for the logger
|
|
64
|
-
this.name = 'Config Warning';
|
|
65
60
|
this.configKey = configKey ?? null;
|
|
66
61
|
this.checkSlug = checkSlug;
|
|
67
62
|
this.received = received;
|
|
@@ -78,7 +73,7 @@ import formatErrorMessage from '../formatErrorMessage.js';
|
|
|
78
73
|
this.link = null;
|
|
79
74
|
return;
|
|
80
75
|
}
|
|
81
|
-
// Resolve location based on available info
|
|
76
|
+
// Resolve location based on available info
|
|
82
77
|
let location = null;
|
|
83
78
|
const configDir = configDirectory ?? context?.directories?.config;
|
|
84
79
|
if (configKey && context?.keyMap) {
|
|
@@ -86,14 +81,12 @@ import formatErrorMessage from '../formatErrorMessage.js';
|
|
|
86
81
|
configKey,
|
|
87
82
|
context
|
|
88
83
|
});
|
|
89
|
-
}
|
|
90
|
-
if (!location && operatorLocation && context?.refMap) {
|
|
84
|
+
} else if (operatorLocation && context?.refMap) {
|
|
91
85
|
location = ConfigMessage.resolveOperatorLocation({
|
|
92
86
|
operatorLocation,
|
|
93
87
|
context
|
|
94
88
|
});
|
|
95
|
-
}
|
|
96
|
-
if (!location && filePath) {
|
|
89
|
+
} else if (filePath) {
|
|
97
90
|
location = ConfigMessage.resolveRawLocation({
|
|
98
91
|
filePath,
|
|
99
92
|
lineNumber,
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* configDirectory: '/Users/dev/myapp'
|
|
32
32
|
* });
|
|
33
33
|
* // Returns: {
|
|
34
|
-
* // source: '
|
|
34
|
+
* // source: 'pages/home.yaml:5',
|
|
35
35
|
* // config: 'root.pages[0:home].blocks[0:header]',
|
|
36
36
|
* // link: '/Users/dev/myapp/pages/home.yaml:5'
|
|
37
37
|
* // }
|
|
@@ -44,18 +44,20 @@
|
|
|
44
44
|
const lineNumber = keyEntry['~l'];
|
|
45
45
|
const refEntry = refMap?.[refId];
|
|
46
46
|
const filePath = refEntry?.path || 'lowdefy.yaml';
|
|
47
|
+
// source: filepath:line (e.g., "lowdefy.yaml:16")
|
|
48
|
+
const source = lineNumber ? `${filePath}:${lineNumber}` : filePath;
|
|
47
49
|
// config: the config path (e.g., "root.pages[0:home].blocks[0:header]")
|
|
48
50
|
const config = keyEntry.key;
|
|
49
|
-
//
|
|
50
|
-
let
|
|
51
|
+
// Absolute path for clickable links in VSCode terminal
|
|
52
|
+
let link = null;
|
|
51
53
|
if (configDirectory) {
|
|
52
|
-
|
|
54
|
+
const absolutePath = path.resolve(configDirectory, filePath);
|
|
55
|
+
link = lineNumber ? `${absolutePath}:${lineNumber}` : absolutePath;
|
|
53
56
|
}
|
|
54
|
-
const source = lineNumber ? `${resolvedPath}:${lineNumber}` : resolvedPath;
|
|
55
57
|
return {
|
|
56
58
|
source,
|
|
57
59
|
config,
|
|
58
|
-
link
|
|
60
|
+
link
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
export default resolveConfigLocation;
|
package/dist/client/index.js
CHANGED
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
* await error.resolve(lowdefy);
|
|
25
25
|
*/ import ConfigError from './ConfigError.js';
|
|
26
26
|
import ConfigWarning from '../ConfigWarning.js';
|
|
27
|
-
import LowdefyError from '
|
|
27
|
+
import LowdefyError from '../LowdefyError.js';
|
|
28
28
|
import PluginError from '../PluginError.js';
|
|
29
29
|
import ServiceError from '../ServiceError.js';
|
|
30
|
-
|
|
31
|
-
export { ConfigError, ConfigWarning, LowdefyError, PluginError, ServiceError, UserError };
|
|
30
|
+
export { ConfigError, ConfigWarning, LowdefyError, PluginError, ServiceError };
|
package/dist/index.js
CHANGED
|
@@ -45,5 +45,4 @@ import ConfigWarning from './ConfigWarning.js';
|
|
|
45
45
|
import LowdefyError from './LowdefyError.js';
|
|
46
46
|
import PluginError from './PluginError.js';
|
|
47
47
|
import ServiceError from './ServiceError.js';
|
|
48
|
-
|
|
49
|
-
export { ConfigError, ConfigWarning, LowdefyError, PluginError, ServiceError, UserError };
|
|
48
|
+
export { ConfigError, ConfigWarning, LowdefyError, PluginError, ServiceError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/errors",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-20260204112702",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy error classes for consistent error handling across build, server, and client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
package/dist/UserError.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ import formatErrorMessage from './formatErrorMessage.js';
|
|
16
|
-
let UserError = class UserError extends Error {
|
|
17
|
-
print() {
|
|
18
|
-
return formatErrorMessage(this);
|
|
19
|
-
}
|
|
20
|
-
constructor(message, { blockId, metaData, pageId } = {}){
|
|
21
|
-
super(message);
|
|
22
|
-
this.name = 'UserError';
|
|
23
|
-
this.blockId = blockId;
|
|
24
|
-
this.metaData = metaData;
|
|
25
|
-
this.pageId = pageId;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
export default UserError;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ import BaseLowdefyError from '../LowdefyError.js';
|
|
16
|
-
/**
|
|
17
|
-
* Client-side LowdefyError with server logging via API.
|
|
18
|
-
*
|
|
19
|
-
* Extends the base LowdefyError to add a log() method that sends
|
|
20
|
-
* the error to /api/client-error for terminal logging, then logs
|
|
21
|
-
* to the browser console.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const error = new LowdefyError('Unexpected condition');
|
|
25
|
-
* await error.log(lowdefy);
|
|
26
|
-
*/ let LowdefyError = class LowdefyError extends BaseLowdefyError {
|
|
27
|
-
/**
|
|
28
|
-
* Sends the error to the server for terminal logging and logs to console.
|
|
29
|
-
* @param {Object} [lowdefy] - Lowdefy context with basePath
|
|
30
|
-
* @param {Object} [options]
|
|
31
|
-
* @param {number} [options.timeout=1000] - Fetch timeout in ms
|
|
32
|
-
* @returns {Promise<void>}
|
|
33
|
-
*/ async log(lowdefy, { timeout = 1000 } = {}) {
|
|
34
|
-
const basePath = lowdefy?.basePath ?? '';
|
|
35
|
-
const controller = new AbortController();
|
|
36
|
-
const timeoutId = setTimeout(()=>controller.abort(), timeout);
|
|
37
|
-
try {
|
|
38
|
-
await fetch(`${basePath}/api/client-error`, {
|
|
39
|
-
method: 'POST',
|
|
40
|
-
headers: {
|
|
41
|
-
'Content-Type': 'application/json'
|
|
42
|
-
},
|
|
43
|
-
body: JSON.stringify(this.serialize()),
|
|
44
|
-
signal: controller.signal,
|
|
45
|
-
credentials: 'same-origin'
|
|
46
|
-
});
|
|
47
|
-
clearTimeout(timeoutId);
|
|
48
|
-
} catch {
|
|
49
|
-
clearTimeout(timeoutId);
|
|
50
|
-
// Server logging failed - continue with local console
|
|
51
|
-
}
|
|
52
|
-
console.error(this.print());
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
export default LowdefyError;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2024 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ function formatErrorMessage(error, { includePrefix = true } = {}) {
|
|
16
|
-
if (typeof error === 'string') return error;
|
|
17
|
-
let message = error?.message || error?.rawMessage || error?.cause?.message || 'Unknown error';
|
|
18
|
-
if (error?.received !== undefined) {
|
|
19
|
-
try {
|
|
20
|
-
message = `${message} Received: ${JSON.stringify(error.received)}`;
|
|
21
|
-
} catch {
|
|
22
|
-
message = `${message} Received: [unserializable]`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (includePrefix) {
|
|
26
|
-
const name = error?.name || 'Error';
|
|
27
|
-
return `[${name}] ${message}`;
|
|
28
|
-
}
|
|
29
|
-
return message;
|
|
30
|
-
}
|
|
31
|
-
export default formatErrorMessage;
|