Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.4.0

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.

```sh


## 0.3.0 — 2026-10-08

- Useful structured API/CLI additions described in README.
Expand All @@ -22,3 +29,4 @@
- Plain-English translations for ECONNREFUSED, ENOENT, EADDRINUSE, MODULE_NOT_FOUND, ERR_MODULE_NOT_FOUND, and TypeError.
- Structured results, text rendering, and CLI with JSON output.
- Automated tests, linting, formatting, and Node 22/24 CI.
```
6 changes: 6 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
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.

Install 0.3.0 with npm. Seeds and exact humorous wording are version-specific. Do not treat jokes or heuristic scores as production evidence.

## 0.3.0 to 0.4.0

46 distinct error definitions with explanations, causes and practical checks; original duck commentary for each; structured errorCatalog API and --catalog CLI.

Default behavior is retained except that the expanded error catalog now recognizes additional errors. New rotation and release-plan features are opt-in.
76 changes: 67 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# error-translator

> **Version 0.3.0:** install from npm with Node 22.13+ or Node 24. See MIGRATION.md for changes from 0.2.0.
## Browse the debugging library (0.4.0)

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.

```sh
npx @deployanyway/error-translator ERR_HTTP_HEADERS_SENT --mode rubber-duck
npx @deployanyway/error-translator --catalog --json
npx @deployanyway/error-translator --list
```

```js
import { errorCatalog, translateError } from "@deployanyway/error-translator";
console.log(errorCatalog({ mode: "plain" }));
console.log(translateError({ code: "EACCES", message: "open config.json" }));
```

`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.

> **Version 0.4.0:** install from npm with Node 22.13+ or Node 24. See MIGRATION.md for changes from 0.2.0.

[![npm version](https://img.shields.io/npm/v/%40deployanyway%2Ferror-translator)](https://www.npmjs.com/package/@deployanyway/error-translator)
[![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)
Expand Down Expand Up @@ -84,14 +102,54 @@ Invalid result shapes throw TypeError.

### Built-in errors

| Code/name | Guidance |
| -------------------- | ------------------------------------------ |
| ECONNREFUSED | Service availability, host, port, firewall |
| ENOENT | Missing paths and working directories |
| EADDRINUSE | Port conflicts and duplicate instances |
| MODULE_NOT_FOUND | CommonJS dependencies and paths |
| ERR_MODULE_NOT_FOUND | ES module dependencies, paths, extensions |
| TypeError | Unexpected types and null/undefined values |
| Code/name | Guidance |
| ------------------------------ | --------------------------------- |
| EACCES | Permission denied |
| EPERM | Operation not permitted |
| EEXIST | Target already exists |
| ENOTDIR | Expected a directory |
| EISDIR | Expected a file |
| ENOTEMPTY | Directory is not empty |
| EMFILE | Too many open files |
| ENFILE | System file table exhausted |
| ENOSPC | No space left |
| EROFS | Read-only filesystem |
| EBUSY | Resource busy |
| EXDEV | Cross-device operation |
| EPIPE | Broken pipe |
| ECONNRESET | Connection reset |
| ETIMEDOUT | Operation timed out |
| ENOTFOUND | Name lookup failed |
| EAI_AGAIN | Temporary name lookup failure |
| EADDRNOTAVAIL | Local address unavailable |
| ECONNABORTED | Connection aborted |
| ENETUNREACH | Network unreachable |
| EHOSTUNREACH | Host unreachable |
| EINVAL | Invalid argument |
| ABORT_ERR | Operation aborted |
| ERR_INVALID_ARG_TYPE | Wrong argument type |
| ERR_INVALID_ARG_VALUE | Invalid argument value |
| ERR_OUT_OF_RANGE | Value outside allowed range |
| ERR_HTTP_HEADERS_SENT | Headers already sent |
| ERR_HTTP_INVALID_STATUS_CODE | Invalid HTTP status |
| ERR_INVALID_URL | Invalid URL |
| ERR_PACKAGE_PATH_NOT_EXPORTED | Package path not exported |
| ERR_PACKAGE_IMPORT_NOT_DEFINED | Package import not defined |
| ERR_INVALID_PACKAGE_CONFIG | Invalid package configuration |
| ERR_UNKNOWN_FILE_EXTENSION | Unknown module file extension |
| ERR_IMPORT_ATTRIBUTE_MISSING | Required import attribute missing |
| ERR_STREAM_WRITE_AFTER_END | Write after stream end |
| ERR_STREAM_DESTROYED | Stream destroyed |
| ERR_SOCKET_BAD_PORT | Invalid socket port |
| SyntaxError | Invalid JavaScript syntax |
| ReferenceError | Name is not available |
| RangeError | Value exceeds a permitted range |
| ECONNREFUSED | Connection refused |
| ENOENT | File or directory not found |
| EADDRINUSE | Address already in use |
| MODULE_NOT_FOUND | Module not found |
| ERR_MODULE_NOT_FOUND | ES module not found |
| TypeError | Unexpected value type |

Translations describe likely causes, not a diagnosis. Keep the original error
and stack trace for context. No AI API or remote service is used.
Expand Down
10 changes: 8 additions & 2 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.3.0 — 2026-10-08
# 0.4.0 — 2026-10-08

Adds useful API/CLI capabilities, TypeScript and CommonJS, coverage and installed-archive gates, and consistent contributor documentation. See README and MIGRATION.md for behavior and compatibility. Published through the repository’s trusted GitHub Actions workflow.
46 distinct error definitions with explanations, causes and practical checks; original duck commentary for each; structured errorCatalog API and --catalog CLI.

Requires Node 22.13+ or 24. See README for copyable CLI and API examples. All required source, type, coverage and installed archive checks passed locally; CI must pass on the final PR head before merging. Original content, MIT code, no backend calls from the libraries.

## Compatibility

Existing APIs remain available; new modes are explicit. Expanded error matching may recognize codes that were previously unknown.
2 changes: 2 additions & 0 deletions index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export function translateErrors(
): Translation[];
export function renderTranslation(result: Translation): string;
export function listErrors(): string[];

export function errorCatalog(options?: TranslationOptions): Translation[];
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export function translateErrors(
): Translation[];
export function renderTranslation(result: Translation): string;
export function listErrors(): string[];

export function errorCatalog(options?: TranslationOptions): Translation[];
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deployanyway/error-translator",
"version": "0.3.0",
"version": "0.4.0",
"description": "Plain-English Node.js error explanations and debugging tips, because the stack trace has chosen violence.",
"type": "module",
"exports": {
Expand Down
17 changes: 16 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
renderTranslation,
translateErrors,
listErrors,
errorCatalog,
} from "./index.js";

import { readStdin } from "./input.js";
Expand All @@ -19,19 +20,33 @@ try {
json: { type: "boolean" },
batch: { type: "boolean" },
list: { type: "boolean" },
catalog: { type: "boolean" },
mode: { type: "string", default: "plain" },
},
});
if (values.help) {
console.log(
'Usage: error-translator <error code or quoted message> [--json] [--mode plain|rubber-duck]\n\nTranslate errors into human-readable guidance. Without arguments, read stdin (256 KiB). --batch reads a JSON array of 1–100 errors. --list lists supported codes.\n\nOptions:\n -h, --help Show help\n -v, --version Show version\n --json Print a structured JSON result\n --mode plain|rubber-duck Keep useful guidance; add duck commentary\n\nExamples:\n error-translator ECONNREFUSED\n error-translator "TypeError: value is not a function" --json\n\nExit codes: 0 translation/help/version; 2 invalid arguments.',
'Usage: error-translator <error code or quoted message> [--json] [--mode plain|rubber-duck]\n\nTranslate errors into human-readable guidance. Without arguments, read stdin (256 KiB). --batch reads a JSON array of 1–100 errors. --list lists supported codes. --catalog prints all explanations and checks.\n\nOptions:\n -h, --help Show help\n -v, --version Show version\n --json Print a structured JSON result\n --mode plain|rubber-duck Keep useful guidance; add duck commentary\n\nExamples:\n error-translator ECONNREFUSED\n error-translator "TypeError: value is not a function" --json\n\nExit codes: 0 translation/help/version; 2 invalid arguments.',
);
} else if (values.version) {
console.log(
JSON.parse(
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
).version,
);
} else if (values.catalog) {
if (positionals.length || values.batch || values.list)
throw new TypeError(
"--catalog does not accept input, --batch or --list.",
);
const catalog = errorCatalog({ mode: values.mode });
console.log(
values.json
? JSON.stringify(catalog, null, 2)
: catalog
.map((item) => item.code + " — " + renderTranslation(item))
.join("\n\n---\n\n"),
);
} else if (values.list) {
if (positionals.length || values.batch)
throw new TypeError("--list does not accept input or --batch.");
Expand Down
2 changes: 2 additions & 0 deletions src/definitions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { extraDefinitions } from "./extra-definitions.js";
// Keep technical guidance here so contributors can add errors without changing logic.
export const definitions = {
...extraDefinitions,
ECONNREFUSED: {
title: "Connection refused",
explanation:
Expand Down
Loading
Loading