basyx-typescript-sdk 2.3.0 → 2.3.1
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/bundle/index.cjs +9 -2
- package/bundle/index.cjs.map +1 -1
- package/bundle/index.mjs +9 -2
- package/bundle/index.mjs.map +1 -1
- package/dist/lib/errorHandler.js +9 -4
- package/package.json +1 -1
package/dist/lib/errorHandler.js
CHANGED
|
@@ -10,6 +10,13 @@ function isResponseErrorLike(err) {
|
|
|
10
10
|
function isRequiredErrorLike(err) {
|
|
11
11
|
return err instanceof RequiredError || err?.name === 'RequiredError';
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns the current time as a UTC date-time string matching the timestamp
|
|
15
|
+
* pattern of the AAS API Message schema.
|
|
16
|
+
*/
|
|
17
|
+
function currentTimestamp() {
|
|
18
|
+
return new Date().toISOString();
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
21
|
* Processes errors from API calls and standardizes them to a Result object
|
|
15
22
|
* with a consistent messages array following the API spec guidelines.
|
|
@@ -24,8 +31,7 @@ export async function handleApiError(err) {
|
|
|
24
31
|
if (errorAny?.messages && Array.isArray(errorAny.messages)) {
|
|
25
32
|
return { messages: errorAny.messages };
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
const timestamp = (new Date().getTime() / 1000).toString();
|
|
34
|
+
const timestamp = currentTimestamp();
|
|
29
35
|
let message = {
|
|
30
36
|
code: '500',
|
|
31
37
|
messageType: 'Exception',
|
|
@@ -89,8 +95,7 @@ export async function handleApiError(err) {
|
|
|
89
95
|
catch (handlerError) {
|
|
90
96
|
// If our error handler throws an error, capture that and return a fallback error
|
|
91
97
|
console.error('Error in error handler:', handlerError);
|
|
92
|
-
|
|
93
|
-
const timestamp = (new Date().getTime() / 1000).toString();
|
|
98
|
+
const timestamp = currentTimestamp();
|
|
94
99
|
return {
|
|
95
100
|
messages: [
|
|
96
101
|
{
|
package/package.json
CHANGED