@lowdefy/errors 0.0.0-experimental-20260927140906 → 0.0.0-experimental-20260928105334
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/ServiceError.js +8 -24
- package/dist/errorToDisplayString.js +1 -4
- package/dist/index.js +4 -20
- package/dist/lowdefyErrorTypes.js +0 -6
- package/dist/shouldSuppressBuildCheck.js +1 -7
- package/package.json +1 -1
- package/dist/AuthorizationError.js +0 -31
- package/dist/TwoFactorEnrolmentRequiredError.js +0 -31
package/dist/ServiceError.js
CHANGED
|
@@ -52,24 +52,15 @@
|
|
|
52
52
|
/**
|
|
53
53
|
* Checks if an error is a service error (network issues, timeouts, 5xx).
|
|
54
54
|
* @param {Error} error - The error to check
|
|
55
|
-
* @param {Set} [seen] - Errors already checked, so a cyclic cause chain ends
|
|
56
55
|
* @returns {boolean} True if this is a service error
|
|
57
|
-
*/ static isServiceError(error
|
|
58
|
-
if (!error
|
|
59
|
-
seen.add(error);
|
|
60
|
-
// A client that retried and gave up (the AI SDK's RetryError) carries the
|
|
61
|
-
// failure it retried on; its own message and fields hold no status.
|
|
62
|
-
if (error.lastError) {
|
|
63
|
-
return ServiceError.isServiceError(error.lastError, seen);
|
|
64
|
-
}
|
|
56
|
+
*/ static isServiceError(error) {
|
|
57
|
+
if (!error) return false;
|
|
65
58
|
// Check error code
|
|
66
59
|
if (error.code && SERVICE_ERROR_CODES.has(error.code)) {
|
|
67
60
|
return true;
|
|
68
61
|
}
|
|
69
|
-
// Check HTTP status codes (5xx = server error)
|
|
70
|
-
|
|
71
|
-
// HTTP status as `code`.
|
|
72
|
-
const statusCode = error.statusCode ?? error.status ?? error.response?.status ?? error.$metadata?.httpStatusCode ?? (Number.isInteger(error.code) ? error.code : undefined);
|
|
62
|
+
// Check HTTP status codes (5xx = server error)
|
|
63
|
+
const statusCode = error.statusCode ?? error.status ?? error.response?.status;
|
|
73
64
|
if (statusCode && statusCode >= 500 && statusCode < 600) {
|
|
74
65
|
return true;
|
|
75
66
|
}
|
|
@@ -78,9 +69,7 @@
|
|
|
78
69
|
if (message.includes('network') || message.includes('timeout') || message.includes('connection refused') || message.includes('dns lookup failed') || message.includes('socket hang up') || message.includes('certificate') || message.includes('unavailable')) {
|
|
79
70
|
return true;
|
|
80
71
|
}
|
|
81
|
-
|
|
82
|
-
// SDK's "Cannot connect to API" around a refused or timed-out fetch).
|
|
83
|
-
return ServiceError.isServiceError(error.cause, seen);
|
|
72
|
+
return false;
|
|
84
73
|
}
|
|
85
74
|
/**
|
|
86
75
|
* Enhances an error message with more helpful context.
|
|
@@ -115,12 +104,10 @@
|
|
|
115
104
|
* @param {string} [options.code] - Error code (e.g., 'ECONNREFUSED')
|
|
116
105
|
* @param {number} [options.statusCode] - HTTP status code if applicable
|
|
117
106
|
* @param {string} [options.configKey] - Config key for location resolution
|
|
118
|
-
|
|
119
|
-
* failure. Enumerable, so it survives serialization to the client.
|
|
120
|
-
*/ constructor(message, { cause, service, code, statusCode, configKey, hint } = {}){
|
|
107
|
+
*/ constructor(message, { cause, service, code, statusCode, configKey } = {}){
|
|
121
108
|
// Extract info from wrapped error if provided
|
|
122
109
|
const errorCode = code ?? cause?.code;
|
|
123
|
-
const errorStatusCode = statusCode ?? cause?.statusCode ?? cause?.status ?? cause?.response?.status
|
|
110
|
+
const errorStatusCode = statusCode ?? cause?.statusCode ?? cause?.status ?? cause?.response?.status;
|
|
124
111
|
// Use provided message, or enhance wrapped error's message
|
|
125
112
|
const baseMessage = message ?? (cause ? ServiceError.enhanceMessage(cause) : 'Service error');
|
|
126
113
|
// Message without prefix - logger uses error.name for display
|
|
@@ -134,11 +121,8 @@
|
|
|
134
121
|
this._message = baseMessage;
|
|
135
122
|
this.service = service;
|
|
136
123
|
this.code = errorCode;
|
|
137
|
-
this.hint = hint ?? cause?.hint ?? null;
|
|
138
124
|
this.statusCode = errorStatusCode;
|
|
139
|
-
|
|
140
|
-
// wrapped around an error that already resolved its config location keeps it.
|
|
141
|
-
this.configKey = configKey ?? cause?.configKey ?? null;
|
|
125
|
+
this.configKey = configKey ?? null;
|
|
142
126
|
}
|
|
143
127
|
};
|
|
144
128
|
export default ServiceError;
|
|
@@ -16,10 +16,7 @@
|
|
|
16
16
|
if (typeof error === 'string') return error;
|
|
17
17
|
if (error?.message === undefined) return String(error);
|
|
18
18
|
const name = error.name || 'Error';
|
|
19
|
-
|
|
20
|
-
// the name segment says so wherever the error is displayed.
|
|
21
|
-
const nameSegment = error.prodError === true ? `${name} · fails in prod` : name;
|
|
22
|
-
let msg = `[${nameSegment}] ${error.message}`;
|
|
19
|
+
let msg = `[${name}] ${error.message}`;
|
|
23
20
|
if (error.received !== undefined) {
|
|
24
21
|
try {
|
|
25
22
|
msg = `${msg} Received: ${JSON.stringify(error.received)}`;
|
package/dist/index.js
CHANGED
|
@@ -42,13 +42,9 @@
|
|
|
42
42
|
* - Extends ConfigError with name override
|
|
43
43
|
* - Format: source:line\n[ConfigWarning] message
|
|
44
44
|
*
|
|
45
|
-
* 6. UserError -
|
|
46
|
-
* - Thrown: Client-side Throw
|
|
47
|
-
*
|
|
48
|
-
* the attempt (4xx: wrong password, expired or used link, invalid code, stale OAuth query)
|
|
49
|
-
* - Caught: Caller of the action/resolver; the message is shown to the user and catch actions
|
|
50
|
-
* run, but it logs to the browser console only - never posted to /api/client-error, never
|
|
51
|
-
* logged on the server at error level, never resolved to a config location
|
|
45
|
+
* 6. UserError - User-authored deliberate failure
|
|
46
|
+
* - Thrown: Client-side Throw action; server-side controlThrow (routine :throw) and controlReject (routine :reject)
|
|
47
|
+
* - Caught: Caller of the action/resolver; signals "the called routine deliberately failed" as distinct from a system fault
|
|
52
48
|
* - Format: [User Error] message
|
|
53
49
|
*
|
|
54
50
|
* 7. AuthenticationError - Unauthenticated request to a protected endpoint
|
|
@@ -56,16 +52,6 @@
|
|
|
56
52
|
* - Caught: Server error handlers, before structured logging and Sentry (401)
|
|
57
53
|
* - Format: [AuthenticationError] message
|
|
58
54
|
*
|
|
59
|
-
* 8. TwoFactorEnrolmentRequiredError - Authorized caller with no enrolled second factor
|
|
60
|
-
* - Thrown: The authorization gate, when auth.twoFactor.required is set and the caller is unenrolled
|
|
61
|
-
* - Caught: Server error handlers, before structured logging and Sentry (403)
|
|
62
|
-
* - Format: [TwoFactorEnrolmentRequiredError] message
|
|
63
|
-
*
|
|
64
|
-
* 9. AuthorizationError - Authenticated caller refused by an authorization gate (wrong roles)
|
|
65
|
-
* - Thrown: Request, endpoint, agent, websocket and auth-step authorization gates
|
|
66
|
-
* - Caught: Server error handlers, before structured logging and Sentry (403)
|
|
67
|
-
* - Format: [AuthorizationError] message
|
|
68
|
-
*
|
|
69
55
|
* Location Resolution Utilities:
|
|
70
56
|
* resolveConfigLocation - Sync: configKey → {source, config} via keyMap/refMap
|
|
71
57
|
* resolveErrorLocation - Sync: unified resolver (configKey or filePath/lineNumber)
|
|
@@ -78,7 +64,6 @@
|
|
|
78
64
|
* lowdefyErrorTypes - Lowdefy error class by name, for reviving and reshaping errors
|
|
79
65
|
*/ import ActionError from './ActionError.js';
|
|
80
66
|
import AuthenticationError from './AuthenticationError.js';
|
|
81
|
-
import AuthorizationError from './AuthorizationError.js';
|
|
82
67
|
import BlockError from './BlockError.js';
|
|
83
68
|
import BuildError from './BuildError.js';
|
|
84
69
|
import ConfigError from './ConfigError.js';
|
|
@@ -96,6 +81,5 @@ import loadAndResolveErrorLocation from './loadAndResolveErrorLocation.js';
|
|
|
96
81
|
import resolveErrorLocation from './resolveErrorLocation.js';
|
|
97
82
|
import ServiceError from './ServiceError.js';
|
|
98
83
|
import shouldSuppressBuildCheck, { VALID_CHECK_SLUGS } from './shouldSuppressBuildCheck.js';
|
|
99
|
-
import TwoFactorEnrolmentRequiredError from './TwoFactorEnrolmentRequiredError.js';
|
|
100
84
|
import UserError from './UserError.js';
|
|
101
|
-
export { ActionError, AuthenticationError,
|
|
85
|
+
export { ActionError, AuthenticationError, BlockError, BuildError, ConfigError, ConfigWarning, errorToDisplayString, LowdefyInternalError, lowdefyErrorNames, lowdefyErrorTypes, OperatorError, PluginError, readErrorCodes, RequestError, resolveConfigLocation, loadAndResolveErrorLocation, resolveErrorLocation, ServiceError, shouldSuppressBuildCheck, UserError, VALID_CHECK_SLUGS };
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import ActionError from './ActionError.js';
|
|
16
|
-
import AuthenticationError from './AuthenticationError.js';
|
|
17
|
-
import AuthorizationError from './AuthorizationError.js';
|
|
18
16
|
import BlockError from './BlockError.js';
|
|
19
17
|
import BuildError from './BuildError.js';
|
|
20
18
|
import ConfigError from './ConfigError.js';
|
|
@@ -24,14 +22,11 @@ import OperatorError from './OperatorError.js';
|
|
|
24
22
|
import PluginError from './PluginError.js';
|
|
25
23
|
import RequestError from './RequestError.js';
|
|
26
24
|
import ServiceError from './ServiceError.js';
|
|
27
|
-
import TwoFactorEnrolmentRequiredError from './TwoFactorEnrolmentRequiredError.js';
|
|
28
25
|
import UserError from './UserError.js';
|
|
29
26
|
// Name to class, for rebuilding an error whose class identity is gone but whose
|
|
30
27
|
// name survived - a serializer round trip, or a caught error being reshaped.
|
|
31
28
|
const lowdefyErrorTypes = {
|
|
32
29
|
ActionError,
|
|
33
|
-
AuthenticationError,
|
|
34
|
-
AuthorizationError,
|
|
35
30
|
BlockError,
|
|
36
31
|
BuildError,
|
|
37
32
|
ConfigError,
|
|
@@ -41,7 +36,6 @@ const lowdefyErrorTypes = {
|
|
|
41
36
|
PluginError,
|
|
42
37
|
RequestError,
|
|
43
38
|
ServiceError,
|
|
44
|
-
TwoFactorEnrolmentRequiredError,
|
|
45
39
|
UserError
|
|
46
40
|
};
|
|
47
41
|
export default lowdefyErrorTypes;
|
|
@@ -23,14 +23,8 @@
|
|
|
23
23
|
'link-refs': 'Invalid Link action page reference warnings',
|
|
24
24
|
'request-refs': 'Invalid Request action reference warnings',
|
|
25
25
|
'connection-refs': 'Nonexistent connection ID references',
|
|
26
|
-
'callapi-refs': 'Invalid CallAPI action endpoint reference warnings',
|
|
27
|
-
'callapi-internal-refs': 'CallAPI actions targeting InternalApi endpoints',
|
|
28
|
-
'dynamic-endpoint-refs': 'Invalid Dynamic block endpoint reference warnings',
|
|
29
|
-
'websocket-refs': 'Invalid websocket action reference warnings',
|
|
30
|
-
icons: 'Unresolvable icon name warnings',
|
|
31
26
|
types: 'All type validation (blocks, operators, actions, requests, connections)',
|
|
32
|
-
schema: 'JSON schema validation errors'
|
|
33
|
-
secrets: 'Environment variable names that are not set in the build environment'
|
|
27
|
+
schema: 'JSON schema validation errors'
|
|
34
28
|
};
|
|
35
29
|
/**
|
|
36
30
|
* Checks if a build check should be suppressed based on ~ignoreBuildChecks.
|
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-20260928105334",
|
|
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",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2026 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
|
-
*/ // Thrown when an authenticated caller is refused by an authorization gate - the
|
|
16
|
-
// caller holds a session or a strategy credential but not the roles the
|
|
17
|
-
// request, endpoint, agent, websocket or auth step requires. Maps to 403. The
|
|
18
|
-
// message is written by the gate and may stay deliberately generic so it does
|
|
19
|
-
// not reveal what exists. The server error handlers branch on the name before
|
|
20
|
-
// the structured-log and Sentry pipeline: a caller with the wrong roles is
|
|
21
|
-
// expected traffic and produces one warning line, not an error log.
|
|
22
|
-
let AuthorizationError = class AuthorizationError extends Error {
|
|
23
|
-
constructor(message = 'Forbidden.', { cause } = {}){
|
|
24
|
-
super(message, {
|
|
25
|
-
cause
|
|
26
|
-
});
|
|
27
|
-
this.name = 'AuthorizationError';
|
|
28
|
-
this.isLowdefyError = true;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export default AuthorizationError;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2026 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
|
-
*/ // Thrown when an authorized caller has not enrolled a second factor and the
|
|
16
|
-
// deployment sets auth.twoFactor.required. Distinct from AuthenticationError on
|
|
17
|
-
// purpose: a 401 reads to the client as a dead session and bounces the user to
|
|
18
|
-
// sign-in, which is the redirect loop the enrolment gate exists to avoid, so this
|
|
19
|
-
// maps to 403. The server error handlers branch on the name before the
|
|
20
|
-
// structured-log and Sentry pipeline - under required: true this is expected
|
|
21
|
-
// traffic from every unenrolled caller, not a fault.
|
|
22
|
-
let TwoFactorEnrolmentRequiredError = class TwoFactorEnrolmentRequiredError extends Error {
|
|
23
|
-
constructor(message = 'Two-factor enrolment required.', { cause } = {}){
|
|
24
|
-
super(message, {
|
|
25
|
-
cause
|
|
26
|
-
});
|
|
27
|
-
this.name = 'TwoFactorEnrolmentRequiredError';
|
|
28
|
-
this.isLowdefyError = true;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export default TwoFactorEnrolmentRequiredError;
|