@deployanyway/error-translator 0.3.0 → 1.0.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+
5
+ - Explain This Failure: real errors and cause chains.
6
+ - Typed API, CLI integration, runnable codebase example and meaningful workflow tests.
7
+ - Stable contracts and migration guidance; original humor stays around accurate facts.
8
+
9
+ ## 0.4.0
10
+
11
+ 46 built-in definitions cover filesystem, permissions, networking, module loading, streams, HTTP response lifecycle and JavaScript errors. Each has a specific explanation, likely causes and practical checks. Rubber-duck commentary has a distinct original line for every supported definition. No commands run automatically and unknown errors remain explicitly unrecognized.
12
+
13
+ ```sh
14
+
15
+
3
16
  ## 0.3.0 — 2026-10-08
4
17
 
5
18
  - Useful structured API/CLI additions described in README.
@@ -22,3 +35,4 @@
22
35
  - Plain-English translations for ECONNREFUSED, ENOENT, EADDRINUSE, MODULE_NOT_FOUND, ERR_MODULE_NOT_FOUND, and TypeError.
23
36
  - Structured results, text rendering, and CLI with JSON output.
24
37
  - Automated tests, linting, formatting, and Node 22/24 CI.
38
+ ```
package/MIGRATION.md CHANGED
@@ -3,3 +3,15 @@
3
3
  Node 22.13+ is required. Existing core APIs remain available; TypeScript declarations and CommonJS exports are new. The CLI now lives in src/cli.js behind the same executable path. Input/stdout behavior for new options is documented in README.
4
4
 
5
5
  Install 0.3.0 with npm. Seeds and exact humorous wording are version-specific. Do not treat jokes or heuristic scores as production evidence.
6
+
7
+ ## 0.3.0 to 0.4.0
8
+
9
+ 46 distinct error definitions with explanations, causes and practical checks; original duck commentary for each; structured errorCatalog API and --catalog CLI.
10
+
11
+ Default behavior is retained except that the expanded error catalog now recognizes additional errors. New rotation and release-plan features are opt-in.
12
+
13
+ ## 0.4.0 to stable 1.0.0
14
+
15
+ diagnoseError/renderDiagnosis and diagnostic CLI flags are additive. Explicit code precedence and existing catalog/batch behavior remain. Use diagnosis.original to hand the same error to your existing handler; serializing a diagnosis omits that reference.
16
+
17
+ See README for exact contracts, bounds and failure behavior.
package/README.md CHANGED
@@ -1,6 +1,54 @@
1
1
  # error-translator
2
2
 
3
- > **Version 0.3.0:** install from npm with Node 22.13+ or Node 24. See MIGRATION.md for changes from 0.2.0.
3
+ ## Explain This Failure: real errors and cause chains (1.0.0)
4
+
5
+ diagnoseError(error, options) walks actual Error.cause chains with a default eight-layer bound (maxDepth 1–32). It detects cycles, exposes unknown causes honestly and returns structured chain entries with a translation for each layer. It never throws away the original error: result.original is the exact input reference and is deliberately non-enumerable so JSON output excludes it. The caller controls rethrowing, logging and exit behavior.
6
+
7
+ ```js
8
+ import { diagnoseError, renderDiagnosis } from "@deployanyway/error-translator";
9
+ try {
10
+ await loadConfig();
11
+ } catch (error) {
12
+ const diagnosis = diagnoseError(error, { mode: "rubber-duck" });
13
+ console.error(renderDiagnosis(diagnosis));
14
+ throw error; // preserve failure behavior and the original stack
15
+ }
16
+ ```
17
+
18
+ Options: mode plain/rubber-duck, maxDepth, includeStack (default false). Entries contain depth, name, message, optional code, translation and opt-in stack. stopped is complete/cycle/depth-limit; truncated reports incomplete traversal. Arbitrary primitive causes receive an explicit unknown translation. The caller's errors and causes are not mutated. AggregateError.errors is not flattened; this API follows the cause chain.
19
+
20
+ ```sh
21
+ printf '%s' '{"message":"Config failed","cause":{"code":"ENOENT","message":"open config.json"}}' | error-translator --diagnose --json
22
+ node node_modules/@deployanyway/error-translator/examples/explain-failure.mjs ./missing-config.json
23
+ ```
24
+
25
+ --diagnose accepts a JSON error record from stdin or a quoted argument, with --max-depth and opt-in --include-stack. It rejects batch/catalog/list combinations. Translation/diagnosis exits 0; invalid input exits 2. The runnable filesystem example preserves application failure with exit 1. Messages and opt-in stacks can contain private data; this library does not redact them or run fixes.
26
+
27
+ ## Stable v1 contract
28
+
29
+ Node 22.13+ or Node 24. MIT licensed. CLI flags, structured fields, ESM/CommonJS exports and declarations are covered by tests and installed-package checks. Existing 0.4 APIs remain available except the explicitly documented doggo-log redaction/text-context changes. Future incompatible public API changes require a major release; callers should consume structured fields rather than parse jokes. Exact humorous wording and seeded catalog choices are version-specific. No telemetry, external API keys or network service is needed for core use.
30
+
31
+ Run npm test, npm run lint, npm run format:check, npm run coverage, npm run test:types and npm run verify:package from a source checkout. Runnable examples are shipped under examples/. The root demo is https://deployanyway.github.io/.
32
+
33
+ ## Browse the debugging library (0.4.0)
34
+
35
+ 46 built-in definitions cover filesystem, permissions, networking, module loading, streams, HTTP response lifecycle and JavaScript errors. Each has a specific explanation, likely causes and practical checks. Rubber-duck commentary has a distinct original line for every supported definition. No commands run automatically and unknown errors remain explicitly unrecognized.
36
+
37
+ ```sh
38
+ npx @deployanyway/error-translator ERR_HTTP_HEADERS_SENT --mode rubber-duck
39
+ npx @deployanyway/error-translator --catalog --json
40
+ npx @deployanyway/error-translator --list
41
+ ```
42
+
43
+ ```js
44
+ import { errorCatalog, translateError } from "@deployanyway/error-translator";
45
+ console.log(errorCatalog({ mode: "plain" }));
46
+ console.log(translateError({ code: "EACCES", message: "open config.json" }));
47
+ ```
48
+
49
+ `errorCatalog(options?)` returns independent structured translations for the complete catalog. `--catalog` prints all guidance, or JSON with `--json`. Explicit codes still take precedence over message matching. This is a focused Node/JavaScript debugging catalog, not diagnosis of every platform or framework error. Technical reference: https://nodejs.org/api/errors.html.
50
+
51
+ > **Version 0.4.0:** install from npm with Node 22.13+ or Node 24. See MIGRATION.md for changes from 0.2.0.
4
52
 
5
53
  [![npm version](https://img.shields.io/npm/v/%40deployanyway%2Ferror-translator)](https://www.npmjs.com/package/@deployanyway/error-translator)
6
54
  [![CI](https://github.com/DeployAnyway/error-translator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/DeployAnyway/error-translator/actions/workflows/ci.yml)
@@ -84,14 +132,54 @@ Invalid result shapes throw TypeError.
84
132
 
85
133
  ### Built-in errors
86
134
 
87
- | Code/name | Guidance |
88
- | -------------------- | ------------------------------------------ |
89
- | ECONNREFUSED | Service availability, host, port, firewall |
90
- | ENOENT | Missing paths and working directories |
91
- | EADDRINUSE | Port conflicts and duplicate instances |
92
- | MODULE_NOT_FOUND | CommonJS dependencies and paths |
93
- | ERR_MODULE_NOT_FOUND | ES module dependencies, paths, extensions |
94
- | TypeError | Unexpected types and null/undefined values |
135
+ | Code/name | Guidance |
136
+ | ------------------------------ | --------------------------------- |
137
+ | EACCES | Permission denied |
138
+ | EPERM | Operation not permitted |
139
+ | EEXIST | Target already exists |
140
+ | ENOTDIR | Expected a directory |
141
+ | EISDIR | Expected a file |
142
+ | ENOTEMPTY | Directory is not empty |
143
+ | EMFILE | Too many open files |
144
+ | ENFILE | System file table exhausted |
145
+ | ENOSPC | No space left |
146
+ | EROFS | Read-only filesystem |
147
+ | EBUSY | Resource busy |
148
+ | EXDEV | Cross-device operation |
149
+ | EPIPE | Broken pipe |
150
+ | ECONNRESET | Connection reset |
151
+ | ETIMEDOUT | Operation timed out |
152
+ | ENOTFOUND | Name lookup failed |
153
+ | EAI_AGAIN | Temporary name lookup failure |
154
+ | EADDRNOTAVAIL | Local address unavailable |
155
+ | ECONNABORTED | Connection aborted |
156
+ | ENETUNREACH | Network unreachable |
157
+ | EHOSTUNREACH | Host unreachable |
158
+ | EINVAL | Invalid argument |
159
+ | ABORT_ERR | Operation aborted |
160
+ | ERR_INVALID_ARG_TYPE | Wrong argument type |
161
+ | ERR_INVALID_ARG_VALUE | Invalid argument value |
162
+ | ERR_OUT_OF_RANGE | Value outside allowed range |
163
+ | ERR_HTTP_HEADERS_SENT | Headers already sent |
164
+ | ERR_HTTP_INVALID_STATUS_CODE | Invalid HTTP status |
165
+ | ERR_INVALID_URL | Invalid URL |
166
+ | ERR_PACKAGE_PATH_NOT_EXPORTED | Package path not exported |
167
+ | ERR_PACKAGE_IMPORT_NOT_DEFINED | Package import not defined |
168
+ | ERR_INVALID_PACKAGE_CONFIG | Invalid package configuration |
169
+ | ERR_UNKNOWN_FILE_EXTENSION | Unknown module file extension |
170
+ | ERR_IMPORT_ATTRIBUTE_MISSING | Required import attribute missing |
171
+ | ERR_STREAM_WRITE_AFTER_END | Write after stream end |
172
+ | ERR_STREAM_DESTROYED | Stream destroyed |
173
+ | ERR_SOCKET_BAD_PORT | Invalid socket port |
174
+ | SyntaxError | Invalid JavaScript syntax |
175
+ | ReferenceError | Name is not available |
176
+ | RangeError | Value exceeds a permitted range |
177
+ | ECONNREFUSED | Connection refused |
178
+ | ENOENT | File or directory not found |
179
+ | EADDRINUSE | Address already in use |
180
+ | MODULE_NOT_FOUND | Module not found |
181
+ | ERR_MODULE_NOT_FOUND | ES module not found |
182
+ | TypeError | Unexpected value type |
95
183
 
96
184
  Translations describe likely causes, not a diagnosis. Keep the original error
97
185
  and stack trace for context. No AI API or remote service is used.