@lowdefy/errors 0.0.0-experimental-20260909201552 → 0.0.0-experimental-20260911113654

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.
@@ -59,10 +59,8 @@
59
59
  if (error.code && SERVICE_ERROR_CODES.has(error.code)) {
60
60
  return true;
61
61
  }
62
- // Check HTTP status codes (5xx = server error). AWS SDK v3 errors carry the
63
- // status on $metadata.httpStatusCode; @google-cloud errors carry the numeric
64
- // HTTP status as `code`.
65
- 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;
66
64
  if (statusCode && statusCode >= 500 && statusCode < 600) {
67
65
  return true;
68
66
  }
@@ -106,9 +104,7 @@
106
104
  * @param {string} [options.code] - Error code (e.g., 'ECONNREFUSED')
107
105
  * @param {number} [options.statusCode] - HTTP status code if applicable
108
106
  * @param {string} [options.configKey] - Config key for location resolution
109
- * @param {string} [options.hint] - A sentence telling the developer what to do about the
110
- * failure. Enumerable, so it survives serialization to the client.
111
- */ constructor(message, { cause, service, code, statusCode, configKey, hint } = {}){
107
+ */ constructor(message, { cause, service, code, statusCode, configKey } = {}){
112
108
  // Extract info from wrapped error if provided
113
109
  const errorCode = code ?? cause?.code;
114
110
  const errorStatusCode = statusCode ?? cause?.statusCode ?? cause?.status ?? cause?.response?.status;
@@ -125,11 +121,8 @@
125
121
  this._message = baseMessage;
126
122
  this.service = service;
127
123
  this.code = errorCode;
128
- this.hint = hint ?? cause?.hint ?? null;
129
124
  this.statusCode = errorStatusCode;
130
- // Extract from the wrapped error like PluginError does, so a ServiceError
131
- // wrapped around an error that already resolved its config location keeps it.
132
- this.configKey = configKey ?? cause?.configKey ?? null;
125
+ this.configKey = configKey ?? null;
133
126
  }
134
127
  };
135
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
- // Prod-gated build warnings are not fatal in dev but fail `lowdefy build`, so
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 - An expected outcome of user interaction, never a config or system fault
46
- * - Thrown: Client-side Throw and Validate actions; server-side controlThrow (routine :throw)
47
- * and controlReject (routine :reject); client auth methods when the auth server rejects
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)
@@ -73,7 +59,6 @@
73
59
  * shouldSuppressBuildCheck - Check ~ignoreBuildChecks in parent chain
74
60
  */ import ActionError from './ActionError.js';
75
61
  import AuthenticationError from './AuthenticationError.js';
76
- import AuthorizationError from './AuthorizationError.js';
77
62
  import BlockError from './BlockError.js';
78
63
  import BuildError from './BuildError.js';
79
64
  import ConfigError from './ConfigError.js';
@@ -88,6 +73,5 @@ import loadAndResolveErrorLocation from './loadAndResolveErrorLocation.js';
88
73
  import resolveErrorLocation from './resolveErrorLocation.js';
89
74
  import ServiceError from './ServiceError.js';
90
75
  import shouldSuppressBuildCheck, { VALID_CHECK_SLUGS } from './shouldSuppressBuildCheck.js';
91
- import TwoFactorEnrolmentRequiredError from './TwoFactorEnrolmentRequiredError.js';
92
76
  import UserError from './UserError.js';
93
- export { ActionError, AuthenticationError, AuthorizationError, BlockError, BuildError, ConfigError, ConfigWarning, errorToDisplayString, LowdefyInternalError, OperatorError, PluginError, RequestError, resolveConfigLocation, loadAndResolveErrorLocation, resolveErrorLocation, ServiceError, shouldSuppressBuildCheck, TwoFactorEnrolmentRequiredError, UserError, VALID_CHECK_SLUGS };
77
+ export { ActionError, AuthenticationError, BlockError, BuildError, ConfigError, ConfigWarning, errorToDisplayString, LowdefyInternalError, OperatorError, PluginError, RequestError, resolveConfigLocation, loadAndResolveErrorLocation, resolveErrorLocation, ServiceError, shouldSuppressBuildCheck, UserError, VALID_CHECK_SLUGS };
@@ -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-20260909201552",
3
+ "version": "0.0.0-experimental-20260911113654",
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;