intellerror 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/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/formatter/index.d.ts +1 -0
- package/dist/index.cjs +174 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/parser/index.d.ts +9 -0
- package/dist/register.cjs +148 -0
- package/dist/register.cjs.map +1 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +124 -0
- package/dist/register.js.map +1 -0
- package/dist/suggestions/index.d.ts +2 -0
- package/dist/suggestions/rules.d.ts +7 -0
- package/examples/async-error.ts +16 -0
- package/examples/basic-usage.ts +18 -0
- package/examples/custom-error.ts +21 -0
- package/examples/express-middleware.ts +19 -0
- package/package.json +64 -0
- package/src/config.ts +31 -0
- package/src/formatter/browser.ts +166 -0
- package/src/formatter/index.ts +120 -0
- package/src/formatter/snapshot.ts +34 -0
- package/src/index.ts +6 -0
- package/src/integrations/webhook.ts +23 -0
- package/src/middleware/index.ts +23 -0
- package/src/parser/index.ts +38 -0
- package/src/register.ts +68 -0
- package/src/suggestions/index.ts +12 -0
- package/src/suggestions/links.ts +12 -0
- package/src/suggestions/rules.ts +236 -0
- package/test.ts +16 -0
- package/tests/config.test.ts +25 -0
- package/tests/rules.test.ts +33 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DarshanBattula
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# 🧠 IntellError
|
|
2
|
+
|
|
3
|
+
**Transform ugly JavaScript/Node.js stack traces into clean, readable, and actionable output. Designed for humans, not robots.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/intellerror)
|
|
6
|
+
[](https://opensource.org/licenses/ISC)
|
|
7
|
+
[](https://github.com/darshan1005/IntellError)
|
|
8
|
+
|
|
9
|
+
## ✨ Why IntellError?
|
|
10
|
+
|
|
11
|
+
Standard error logs are noisy, cluttered with `node_modules`, and lack context. **IntellError** gives you the "Why" and "How to Fix" instantly.
|
|
12
|
+
|
|
13
|
+
- ❌ **Clean Stack Traces**: Auto-hides Node.js internals and collapses `node_modules` noise.
|
|
14
|
+
- 📍 **Smart Highlighting**: Identifies exactly where the error occurred in *your* code.
|
|
15
|
+
- 💡 **Actionable Suggestions**: 50+ built-in rules for React, Express, Node.js, and Browser APIs.
|
|
16
|
+
- 📸 **Code Snapshots**: Sees 3 lines of source code directly in your terminal (Node.js only).
|
|
17
|
+
- 🔍 **One-Click Troubleshooting**: Instant search links for Google, StackOverflow, and GitHub.
|
|
18
|
+
- 🌓 **Intelligent Warnings**: Not just for errors! Also formats `console.warn()` with suggestions.
|
|
19
|
+
- 🌐 **Universal Styling**: Beautiful ANSI colors for Terminal and native `%c` CSS for Browsers.
|
|
20
|
+
- 📢 **Team Integration**: Push critical dev errors directly to **Slack** or **Discord** webhooks.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 Quick Start (Zero-Config)
|
|
25
|
+
|
|
26
|
+
You can set up `IntellError` globally to catch all unhandled issues across your entire project with just one line.
|
|
27
|
+
|
|
28
|
+
### For Browser (React, Vite, Next.js)
|
|
29
|
+
Add this at the very top of your entry file (e.g., `main.tsx` or `index.tsx`):
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import 'intellerror/register';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### For Node.js (CLI)
|
|
36
|
+
Run your application with the register hook:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# ESM (Node.js 20+)
|
|
40
|
+
node --import intellerror/register index.js
|
|
41
|
+
|
|
42
|
+
# CommonJS
|
|
43
|
+
node -r intellerror/register index.js
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ⚙️ Configuration & Customization
|
|
49
|
+
|
|
50
|
+
Fine-tune the output or add your own project-specific intelligence.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { setupConfig, registerRule } from 'intellerror';
|
|
54
|
+
|
|
55
|
+
setupConfig({
|
|
56
|
+
showNodeModules: false, // Hide noise?
|
|
57
|
+
showNodeInternals: false, // Hide node internals?
|
|
58
|
+
suggestionsEnabled: true, // Show the "💡 Suggestions"?
|
|
59
|
+
interceptWarnings: true, // Also format console.warn?
|
|
60
|
+
showSearchLinks: true, // Show troubleshooting links?
|
|
61
|
+
webhookUrl: 'https://...' // Push to Slack/Discord?
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Add your own "Thinking" to the engine
|
|
65
|
+
registerRule({
|
|
66
|
+
match: (err) => err.message.includes("AUTH_FAILED"),
|
|
67
|
+
message: "Authentication failure detected.",
|
|
68
|
+
fix: "Ensure your .env contains a valid API_KEY.",
|
|
69
|
+
description: "The request was rejected by the server due to invalid credentials."
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📖 Manual Usage
|
|
76
|
+
|
|
77
|
+
If you prefer to format specific errors manually in your `try-catch` blocks:
|
|
78
|
+
|
|
79
|
+
### Terminal / Node.js
|
|
80
|
+
```typescript
|
|
81
|
+
import { formatError, formatWarning } from 'intellerror';
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// your code...
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.log(formatError(err));
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Browser Console (React/Vite)
|
|
91
|
+
```typescript
|
|
92
|
+
import { formatErrorBrowser } from 'intellerror';
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
// your React code...
|
|
96
|
+
} catch (err) {
|
|
97
|
+
// Note: MUST use the spread operator (...) for CSS styling
|
|
98
|
+
console.log(...formatErrorBrowser(err));
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🚅 Framework Integration
|
|
105
|
+
|
|
106
|
+
### Express Middleware
|
|
107
|
+
```typescript
|
|
108
|
+
import express from 'express';
|
|
109
|
+
import { errorFormatter } from 'intellerror';
|
|
110
|
+
|
|
111
|
+
const app = express();
|
|
112
|
+
// ... routes ...
|
|
113
|
+
|
|
114
|
+
// Add at the very end of your middleware stack
|
|
115
|
+
app.use(errorFormatter());
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🎮 Demos & Examples
|
|
121
|
+
|
|
122
|
+
We've included several ready-to-run examples in the `examples/` directory:
|
|
123
|
+
|
|
124
|
+
- **Basic Error**: `npm run example:basic`
|
|
125
|
+
- **Async Errors**: `npm run example:async`
|
|
126
|
+
- **Custom Errors**: `npm run example:custom`
|
|
127
|
+
- **Run All**: `npm run examples:all`
|
|
128
|
+
|
|
129
|
+
### Run Unit Tests
|
|
130
|
+
```bash
|
|
131
|
+
npm run test:unit
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Example Output (Terminal)
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
TypeError Cannot read properties of undefined (reading 'name')
|
|
140
|
+
|
|
141
|
+
📍 Location:
|
|
142
|
+
src/index.ts:12:15 ← YOUR CODE
|
|
143
|
+
|
|
144
|
+
> 11 | const user = await fetchUser();
|
|
145
|
+
> 12 | console.log(user.name);
|
|
146
|
+
> 13 | }
|
|
147
|
+
|
|
148
|
+
💡 Suggestions:
|
|
149
|
+
• Accessing property on undefined object.
|
|
150
|
+
Fix: Use optional chaining like 'obj?.prop' or ensure the object is initialized.
|
|
151
|
+
|
|
152
|
+
🔍 Troubleshoot:
|
|
153
|
+
• Google: https://google.com/...
|
|
154
|
+
• GitHub: https://github.com/...
|
|
155
|
+
|
|
156
|
+
📦 Stack:
|
|
157
|
+
→ src/index.ts:12:15
|
|
158
|
+
→ src/server.ts:45:10
|
|
159
|
+
(4 node internals and 2 node_modules hidden)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 📄 License
|
|
163
|
+
|
|
164
|
+
ISC © [darshan1005](https://github.com/darshan1005)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatError(error: Error | unknown): string;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
errorFormatter: () => errorFormatter,
|
|
34
|
+
formatError: () => formatError,
|
|
35
|
+
parseStack: () => parseStack
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/formatter/index.ts
|
|
40
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
41
|
+
|
|
42
|
+
// src/parser/index.ts
|
|
43
|
+
var stackTraceParser = __toESM(require("stacktrace-parser"), 1);
|
|
44
|
+
function parseStack(error) {
|
|
45
|
+
if (!error.stack) return [];
|
|
46
|
+
const parsed = stackTraceParser.parse(error.stack);
|
|
47
|
+
return parsed.map((frame) => {
|
|
48
|
+
const file = frame.file || "";
|
|
49
|
+
const isNodeInternal = file.startsWith("node:") || file.startsWith("internal/") || !file.includes("/") && !file.includes("\\");
|
|
50
|
+
const isNodeModule = file.includes("node_modules");
|
|
51
|
+
return {
|
|
52
|
+
file: frame.file,
|
|
53
|
+
methodName: frame.methodName || "<unknown>",
|
|
54
|
+
lineNumber: frame.lineNumber,
|
|
55
|
+
column: frame.column,
|
|
56
|
+
isNodeInternal: Boolean(isNodeInternal),
|
|
57
|
+
isNodeModule: Boolean(isNodeModule)
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/suggestions/rules.ts
|
|
63
|
+
var rules = [
|
|
64
|
+
{
|
|
65
|
+
match: (err) => err.message.includes("Cannot read properties of undefined (reading '") || err.message.includes("is not defined"),
|
|
66
|
+
message: "Accessing property on undefined/not defined object.",
|
|
67
|
+
fix: "User optional chaining like 'obj?.prop' or ensure the object is initialized.",
|
|
68
|
+
description: "You are trying to read a property from a variable that currently holds an undefined value."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
match: (err) => err instanceof SyntaxError && err.message.includes("Unexpected token"),
|
|
72
|
+
message: "JSON Parsing or Code Syntax error.",
|
|
73
|
+
fix: "Check your JSON string for trailing commas, proper quotes, or syntax issues in your code.",
|
|
74
|
+
description: "The engine encountered something it didn't expect while parsing."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
match: (err) => err.message.includes("is not a function"),
|
|
78
|
+
message: "Attempted to call a non-function value.",
|
|
79
|
+
fix: "Ensure that you're calling a property that is actually a function.",
|
|
80
|
+
description: "You probably tried to execute something that is a string, number, or object as if it were a function."
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
// src/suggestions/index.ts
|
|
85
|
+
function getSuggestions(error) {
|
|
86
|
+
return rules.filter((rule) => rule.match(error));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/formatter/index.ts
|
|
90
|
+
function formatError(error) {
|
|
91
|
+
if (!(error instanceof Error)) {
|
|
92
|
+
return String(error);
|
|
93
|
+
}
|
|
94
|
+
const stackFrames = parseStack(error);
|
|
95
|
+
const userFrame = stackFrames.find((frame) => !frame.isNodeInternal && !frame.isNodeModule);
|
|
96
|
+
const errorType = error.constructor.name || "Error";
|
|
97
|
+
const typeLabel = import_chalk.default.bgRed.white(` ${errorType} `);
|
|
98
|
+
let output = `
|
|
99
|
+
${typeLabel} ${import_chalk.default.red(error.message)}
|
|
100
|
+
|
|
101
|
+
`;
|
|
102
|
+
if (userFrame && userFrame.file) {
|
|
103
|
+
output += `${import_chalk.default.bold("\u{1F4CD} Location:")}
|
|
104
|
+
`;
|
|
105
|
+
output += `${import_chalk.default.cyan(userFrame.file)}:${import_chalk.default.yellow(userFrame.lineNumber)}:${import_chalk.default.yellow(userFrame.column)} ${import_chalk.default.gray("\u2190 YOUR CODE")}
|
|
106
|
+
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
const suggestions = getSuggestions(error);
|
|
110
|
+
if (suggestions.length > 0) {
|
|
111
|
+
output += `${import_chalk.default.bold("\u{1F4A1} Suggestions:")}
|
|
112
|
+
`;
|
|
113
|
+
for (const suggestion of suggestions) {
|
|
114
|
+
output += `\u2022 ${import_chalk.default.green(suggestion.message)}
|
|
115
|
+
`;
|
|
116
|
+
if (suggestion.fix) {
|
|
117
|
+
output += ` ${import_chalk.default.dim("Fix: " + suggestion.fix)}
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
output += `
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
output += `${import_chalk.default.bold("\u{1F4E6} Stack:")}
|
|
125
|
+
`;
|
|
126
|
+
let hiddenInternalsCount = 0;
|
|
127
|
+
let hiddenModulesCount = 0;
|
|
128
|
+
for (const frame of stackFrames) {
|
|
129
|
+
if (frame.isNodeInternal) {
|
|
130
|
+
hiddenInternalsCount++;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (frame.isNodeModule) {
|
|
134
|
+
hiddenModulesCount++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const fileStr = frame.file ? `${import_chalk.default.cyan(frame.file)}:${import_chalk.default.yellow(frame.lineNumber)}:${import_chalk.default.yellow(frame.column)}` : import_chalk.default.gray("<unknown>");
|
|
138
|
+
output += `\u2192 ${fileStr}
|
|
139
|
+
`;
|
|
140
|
+
}
|
|
141
|
+
if (hiddenModulesCount > 0 || hiddenInternalsCount > 0) {
|
|
142
|
+
const hiddenMessages = [];
|
|
143
|
+
if (hiddenModulesCount > 0) hiddenMessages.push(`${hiddenModulesCount} node_modules`);
|
|
144
|
+
if (hiddenInternalsCount > 0) hiddenMessages.push(`${hiddenInternalsCount} node internals`);
|
|
145
|
+
output += import_chalk.default.dim(`(${hiddenMessages.join(" and ")} hidden)
|
|
146
|
+
`);
|
|
147
|
+
}
|
|
148
|
+
return output;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/middleware/index.ts
|
|
152
|
+
function errorFormatter() {
|
|
153
|
+
return (err, _req, res, _next) => {
|
|
154
|
+
const formatted = formatError(err);
|
|
155
|
+
console.error(formatted);
|
|
156
|
+
if (!res.headersSent) {
|
|
157
|
+
res.status(err.status || 500).json({
|
|
158
|
+
error: {
|
|
159
|
+
name: err.name,
|
|
160
|
+
message: err.message
|
|
161
|
+
// We don't send the full formatted error to the client for security,
|
|
162
|
+
// but we provide the basic info.
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
errorFormatter,
|
|
171
|
+
formatError,
|
|
172
|
+
parseStack
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/formatter/index.ts","../src/parser/index.ts","../src/suggestions/rules.ts","../src/suggestions/index.ts","../src/middleware/index.ts"],"sourcesContent":["export { formatError } from './formatter/index.js';\nexport { parseStack } from './parser/index.js';\nexport { errorFormatter } from './middleware/index.js';\n","import chalk from 'chalk';\nimport { parseStack } from '../parser/index.js';\nimport { getSuggestions } from '../suggestions/index.js';\n\nexport function formatError(error: Error | unknown): string {\n if (!(error instanceof Error)) {\n return String(error);\n }\n\n const stackFrames = parseStack(error);\n \n // Find first user frame that is not node internal or node_modules\n const userFrame = stackFrames.find(frame => !frame.isNodeInternal && !frame.isNodeModule);\n\n const errorType = error.constructor.name || 'Error';\n const typeLabel = chalk.bgRed.white(` ${errorType} `);\n let output = `\\n${typeLabel} ${chalk.red(error.message)}\\n\\n`;\n\n if (userFrame && userFrame.file) {\n output += `${chalk.bold('📍 Location:')}\\n`;\n output += `${chalk.cyan(userFrame.file)}:${chalk.yellow(userFrame.lineNumber)}:${chalk.yellow(userFrame.column)} ${chalk.gray('← YOUR CODE')}\\n\\n`;\n }\n\n const suggestions = getSuggestions(error);\n if (suggestions.length > 0) {\n output += `${chalk.bold('💡 Suggestions:')}\\n`;\n for (const suggestion of suggestions) {\n output += `• ${chalk.green(suggestion.message)}\\n`;\n if (suggestion.fix) {\n output += ` ${chalk.dim('Fix: ' + suggestion.fix)}\\n`;\n }\n }\n output += `\\n`;\n }\n\n output += `${chalk.bold('📦 Stack:')}\\n`;\n \n let hiddenInternalsCount = 0;\n let hiddenModulesCount = 0;\n\n for (const frame of stackFrames) {\n if (frame.isNodeInternal) {\n hiddenInternalsCount++;\n continue;\n }\n \n if (frame.isNodeModule) {\n hiddenModulesCount++;\n continue; \n }\n \n const fileStr = frame.file \n ? `${chalk.cyan(frame.file)}:${chalk.yellow(frame.lineNumber)}:${chalk.yellow(frame.column)}` \n : chalk.gray('<unknown>');\n \n output += `→ ${fileStr}\\n`;\n }\n\n if (hiddenModulesCount > 0 || hiddenInternalsCount > 0) {\n const hiddenMessages = [];\n if (hiddenModulesCount > 0) hiddenMessages.push(`${hiddenModulesCount} node_modules`);\n if (hiddenInternalsCount > 0) hiddenMessages.push(`${hiddenInternalsCount} node internals`);\n output += chalk.dim(`(${hiddenMessages.join(' and ')} hidden)\\n`);\n }\n\n return output;\n}\n","import * as stackTraceParser from 'stacktrace-parser';\n\nexport interface ParsedStackFrame {\n file: string | null;\n methodName: string;\n lineNumber: number | null;\n column: number | null;\n isNodeInternal: boolean;\n isNodeModule: boolean;\n}\n\nexport function parseStack(error: Error): ParsedStackFrame[] {\n if (!error.stack) return [];\n \n const parsed = stackTraceParser.parse(error.stack);\n \n return parsed.map(frame => {\n const file = frame.file || '';\n \n // Check if it's a built-in node module or internal\n // e.g. node:internal/... or just internal/... or events.js\n const isNodeInternal = \n file.startsWith('node:') || \n file.startsWith('internal/') ||\n !file.includes('/') && !file.includes('\\\\'); // typically a core module if no path separators\n \n const isNodeModule = file.includes('node_modules');\n\n return {\n file: frame.file,\n methodName: frame.methodName || '<unknown>',\n lineNumber: frame.lineNumber,\n column: frame.column,\n isNodeInternal: Boolean(isNodeInternal),\n isNodeModule: Boolean(isNodeModule)\n };\n });\n}\n","export interface SuggesionRule {\n match: (error: Error) => boolean;\n message: string;\n fix?: string;\n description?: string;\n}\n\nexport const rules: SuggesionRule[] = [\n {\n match: (err) => err.message.includes(\"Cannot read properties of undefined (reading '\") || err.message.includes(\"is not defined\"),\n message: \"Accessing property on undefined/not defined object.\",\n fix: \"User optional chaining like 'obj?.prop' or ensure the object is initialized.\",\n description: \"You are trying to read a property from a variable that currently holds an undefined value.\"\n },\n {\n match: (err) => err instanceof SyntaxError && err.message.includes(\"Unexpected token\"),\n message: \"JSON Parsing or Code Syntax error.\",\n fix: \"Check your JSON string for trailing commas, proper quotes, or syntax issues in your code.\",\n description: \"The engine encountered something it didn't expect while parsing.\"\n },\n {\n match: (err) => err.message.includes(\"is not a function\"),\n message: \"Attempted to call a non-function value.\",\n fix: \"Ensure that you're calling a property that is actually a function.\",\n description: \"You probably tried to execute something that is a string, number, or object as if it were a function.\"\n }\n];\n","import { rules, SuggesionRule } from './rules.js';\n\nexport function getSuggestions(error: Error): SuggesionRule[] {\n return rules.filter(rule => rule.match(error));\n}\n","import { formatError } from '../formatter/index.js';\nimport type { Request, Response, NextFunction } from 'express';\n\nexport function errorFormatter() {\n return (err: any, _req: Request, res: Response, _next: NextFunction) => {\n const formatted = formatError(err);\n \n // Log to console with nice formatting\n console.error(formatted);\n\n // If headers not sent, send a standard error response\n if (!res.headersSent) {\n res.status(err.status || 500).json({\n error: {\n name: err.name,\n message: err.message,\n // We don't send the full formatted error to the client for security, \n // but we provide the basic info.\n },\n });\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;;;ACAlB,uBAAkC;AAW3B,SAAS,WAAW,OAAkC;AAC3D,MAAI,CAAC,MAAM,MAAO,QAAO,CAAC;AAE1B,QAAM,SAA0B,uBAAM,MAAM,KAAK;AAEjD,SAAO,OAAO,IAAI,WAAS;AACzB,UAAM,OAAO,MAAM,QAAQ;AAI3B,UAAM,iBACJ,KAAK,WAAW,OAAO,KACvB,KAAK,WAAW,WAAW,KAC3B,CAAC,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,SAAS,IAAI;AAE5C,UAAM,eAAe,KAAK,SAAS,cAAc;AAEjD,WAAO;AAAA,MACL,MAAM,MAAM;AAAA,MACZ,YAAY,MAAM,cAAc;AAAA,MAChC,YAAY,MAAM;AAAA,M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O;AACT;;;AI/DO,SAAS,iBAAiB;AAC/B,SAAO,CAAC,KAAU,MAAe,KAAe,UAAwB;AACtE,UAAM,YAAY,YAAY,GAAG;AAGjC,YAAQ,MAAM,SAAS;AAGvB,QAAI,CAAC,IAAI,aAAa;AACpB,UAAI,OAAO,IAAI,UAAU,GAAG,EAAE,KAAK;AAAA,QACjC,OAAO;AAAA,UACL,MAAM,IAAI;AAAA,UACV,SAAS,IAAI;AAAA;AAAA;AAAA,QAGf;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["chalk"]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/formatter/index.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
// src/parser/index.ts
|
|
5
|
+
import * as stackTraceParser from "stacktrace-parser";
|
|
6
|
+
function parseStack(error) {
|
|
7
|
+
if (!error.stack) return [];
|
|
8
|
+
const parsed = stackTraceParser.parse(error.stack);
|
|
9
|
+
return parsed.map((frame) => {
|
|
10
|
+
const file = frame.file || "";
|
|
11
|
+
const isNodeInternal = file.startsWith("node:") || file.startsWith("internal/") || !file.includes("/") && !file.includes("\\");
|
|
12
|
+
const isNodeModule = file.includes("node_modules");
|
|
13
|
+
return {
|
|
14
|
+
file: frame.file,
|
|
15
|
+
methodName: frame.methodName || "<unknown>",
|
|
16
|
+
lineNumber: frame.lineNumber,
|
|
17
|
+
column: frame.column,
|
|
18
|
+
isNodeInternal: Boolean(isNodeInternal),
|
|
19
|
+
isNodeModule: Boolean(isNodeModule)
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/suggestions/rules.ts
|
|
25
|
+
var rules = [
|
|
26
|
+
{
|
|
27
|
+
match: (err) => err.message.includes("Cannot read properties of undefined (reading '") || err.message.includes("is not defined"),
|
|
28
|
+
message: "Accessing property on undefined/not defined object.",
|
|
29
|
+
fix: "User optional chaining like 'obj?.prop' or ensure the object is initialized.",
|
|
30
|
+
description: "You are trying to read a property from a variable that currently holds an undefined value."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
match: (err) => err instanceof SyntaxError && err.message.includes("Unexpected token"),
|
|
34
|
+
message: "JSON Parsing or Code Syntax error.",
|
|
35
|
+
fix: "Check your JSON string for trailing commas, proper quotes, or syntax issues in your code.",
|
|
36
|
+
description: "The engine encountered something it didn't expect while parsing."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
match: (err) => err.message.includes("is not a function"),
|
|
40
|
+
message: "Attempted to call a non-function value.",
|
|
41
|
+
fix: "Ensure that you're calling a property that is actually a function.",
|
|
42
|
+
description: "You probably tried to execute something that is a string, number, or object as if it were a function."
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// src/suggestions/index.ts
|
|
47
|
+
function getSuggestions(error) {
|
|
48
|
+
return rules.filter((rule) => rule.match(error));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/formatter/index.ts
|
|
52
|
+
function formatError(error) {
|
|
53
|
+
if (!(error instanceof Error)) {
|
|
54
|
+
return String(error);
|
|
55
|
+
}
|
|
56
|
+
const stackFrames = parseStack(error);
|
|
57
|
+
const userFrame = stackFrames.find((frame) => !frame.isNodeInternal && !frame.isNodeModule);
|
|
58
|
+
const errorType = error.constructor.name || "Error";
|
|
59
|
+
const typeLabel = chalk.bgRed.white(` ${errorType} `);
|
|
60
|
+
let output = `
|
|
61
|
+
${typeLabel} ${chalk.red(error.message)}
|
|
62
|
+
|
|
63
|
+
`;
|
|
64
|
+
if (userFrame && userFrame.file) {
|
|
65
|
+
output += `${chalk.bold("\u{1F4CD} Location:")}
|
|
66
|
+
`;
|
|
67
|
+
output += `${chalk.cyan(userFrame.file)}:${chalk.yellow(userFrame.lineNumber)}:${chalk.yellow(userFrame.column)} ${chalk.gray("\u2190 YOUR CODE")}
|
|
68
|
+
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
const suggestions = getSuggestions(error);
|
|
72
|
+
if (suggestions.length > 0) {
|
|
73
|
+
output += `${chalk.bold("\u{1F4A1} Suggestions:")}
|
|
74
|
+
`;
|
|
75
|
+
for (const suggestion of suggestions) {
|
|
76
|
+
output += `\u2022 ${chalk.green(suggestion.message)}
|
|
77
|
+
`;
|
|
78
|
+
if (suggestion.fix) {
|
|
79
|
+
output += ` ${chalk.dim("Fix: " + suggestion.fix)}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
output += `
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
output += `${chalk.bold("\u{1F4E6} Stack:")}
|
|
87
|
+
`;
|
|
88
|
+
let hiddenInternalsCount = 0;
|
|
89
|
+
let hiddenModulesCount = 0;
|
|
90
|
+
for (const frame of stackFrames) {
|
|
91
|
+
if (frame.isNodeInternal) {
|
|
92
|
+
hiddenInternalsCount++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (frame.isNodeModule) {
|
|
96
|
+
hiddenModulesCount++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const fileStr = frame.file ? `${chalk.cyan(frame.file)}:${chalk.yellow(frame.lineNumber)}:${chalk.yellow(frame.column)}` : chalk.gray("<unknown>");
|
|
100
|
+
output += `\u2192 ${fileStr}
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
if (hiddenModulesCount > 0 || hiddenInternalsCount > 0) {
|
|
104
|
+
const hiddenMessages = [];
|
|
105
|
+
if (hiddenModulesCount > 0) hiddenMessages.push(`${hiddenModulesCount} node_modules`);
|
|
106
|
+
if (hiddenInternalsCount > 0) hiddenMessages.push(`${hiddenInternalsCount} node internals`);
|
|
107
|
+
output += chalk.dim(`(${hiddenMessages.join(" and ")} hidden)
|
|
108
|
+
`);
|
|
109
|
+
}
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/middleware/index.ts
|
|
114
|
+
function errorFormatter() {
|
|
115
|
+
return (err, _req, res, _next) => {
|
|
116
|
+
const formatted = formatError(err);
|
|
117
|
+
console.error(formatted);
|
|
118
|
+
if (!res.headersSent) {
|
|
119
|
+
res.status(err.status || 500).json({
|
|
120
|
+
error: {
|
|
121
|
+
name: err.name,
|
|
122
|
+
message: err.message
|
|
123
|
+
// We don't send the full formatted error to the client for security,
|
|
124
|
+
// but we provide the basic info.
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
errorFormatter,
|
|
132
|
+
formatError,
|
|
133
|
+
parseStack
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formatter/index.ts","../src/parser/index.ts","../src/suggestions/rules.ts","../src/suggestions/index.ts","../src/middleware/index.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { parseStack } from '../parser/index.js';\nimport { getSuggestions } from '../suggestions/index.js';\n\nexport function formatError(error: Error | unknown): string {\n if (!(error instanceof Error)) {\n return String(error);\n }\n\n const stackFrames = parseStack(error);\n \n // Find first user frame that is not node internal or node_modules\n const userFrame = stackFrames.find(frame => !frame.isNodeInternal && !frame.isNodeModule);\n\n const errorType = error.constructor.name || 'Error';\n const typeLabel = chalk.bgRed.white(` ${errorType} `);\n let output = `\\n${typeLabel} ${chalk.red(error.message)}\\n\\n`;\n\n if (userFrame && userFrame.file) {\n output += `${chalk.bold('📍 Location:')}\\n`;\n output += `${chalk.cyan(userFrame.file)}:${chalk.yellow(userFrame.lineNumber)}:${chalk.yellow(userFrame.column)} ${chalk.gray('← YOUR CODE')}\\n\\n`;\n }\n\n const suggestions = getSuggestions(error);\n if (suggestions.length > 0) {\n output += `${chalk.bold('💡 Suggestions:')}\\n`;\n for (const suggestion of suggestions) {\n output += `• ${chalk.green(suggestion.message)}\\n`;\n if (suggestion.fix) {\n output += ` ${chalk.dim('Fix: ' + suggestion.fix)}\\n`;\n }\n }\n output += `\\n`;\n }\n\n output += `${chalk.bold('📦 Stack:')}\\n`;\n \n let hiddenInternalsCount = 0;\n let hiddenModulesCount = 0;\n\n for (const frame of stackFrames) {\n if (frame.isNodeInternal) {\n hiddenInternalsCount++;\n continue;\n }\n \n if (frame.isNodeModule) {\n hiddenModulesCount++;\n continue; \n }\n \n const fileStr = frame.file \n ? `${chalk.cyan(frame.file)}:${chalk.yellow(frame.lineNumber)}:${chalk.yellow(frame.column)}` \n : chalk.gray('<unknown>');\n \n output += `→ ${fileStr}\\n`;\n }\n\n if (hiddenModulesCount > 0 || hiddenInternalsCount > 0) {\n const hiddenMessages = [];\n if (hiddenModulesCount > 0) hiddenMessages.push(`${hiddenModulesCount} node_modules`);\n if (hiddenInternalsCount > 0) hiddenMessages.push(`${hiddenInternalsCount} node internals`);\n output += chalk.dim(`(${hiddenMessages.join(' and ')} hidden)\\n`);\n }\n\n return output;\n}\n","import * as stackTraceParser from 'stacktrace-parser';\n\nexport interface ParsedStackFrame {\n file: string | null;\n methodName: string;\n lineNumber: number | null;\n column: number | null;\n isNodeInternal: boolean;\n isNodeModule: boolean;\n}\n\nexport function parseStack(error: Error): ParsedStackFrame[] {\n if (!error.stack) return [];\n \n const parsed = stackTraceParser.parse(error.stack);\n \n return parsed.map(frame => {\n const file = frame.file || '';\n \n // Check if it's a built-in node module or internal\n // e.g. node:internal/... or just internal/... or events.js\n const isNodeInternal = \n file.startsWith('node:') || \n file.startsWith('internal/') ||\n !file.includes('/') && !file.includes('\\\\'); // typically a core module if no path separators\n \n const isNodeModule = file.includes('node_modules');\n\n return {\n file: frame.file,\n methodName: frame.methodName || '<unknown>',\n lineNumber: frame.lineNumber,\n column: frame.column,\n isNodeInternal: Boolean(isNodeInternal),\n isNodeModule: Boolean(isNodeModule)\n };\n });\n}\n","export interface SuggesionRule {\n match: (error: Error) => boolean;\n message: string;\n fix?: string;\n description?: string;\n}\n\nexport const rules: SuggesionRule[] = [\n {\n match: (err) => err.message.includes(\"Cannot read properties of undefined (reading '\") || err.message.includes(\"is not defined\"),\n message: \"Accessing property on undefined/not defined object.\",\n fix: \"User optional chaining like 'obj?.prop' or ensure the object is initialized.\",\n description: \"You are trying to read a property from a variable that currently holds an undefined value.\"\n },\n {\n match: (err) => err instanceof SyntaxError && err.message.includes(\"Unexpected token\"),\n message: \"JSON Parsing or Code Syntax error.\",\n fix: \"Check your JSON string for trailing commas, proper quotes, or syntax issues in your code.\",\n description: \"The engine encountered something it didn't expect while parsing.\"\n },\n {\n match: (err) => err.message.includes(\"is not a function\"),\n message: \"Attempted to call a non-function value.\",\n fix: \"Ensure that you're calling a property that is actually a function.\",\n description: \"You probably tried to execute something that is a string, number, or object as if it were a function.\"\n }\n];\n","import { rules, SuggesionRule } from './rules.js';\n\nexport function getSuggestions(error: Error): SuggesionRule[] {\n return rules.filter(rule => rule.match(error));\n}\n","import { formatError } from '../formatter/index.js';\nimport type { Request, Response, NextFunction } from 'express';\n\nexport function errorFormatter() {\n return (err: any, _req: Request, res: Response, _next: NextFunction) => {\n const formatted = formatError(err);\n \n // Log to console with nice formatting\n console.error(formatted);\n\n // If headers not sent, send a standard error response\n if (!res.headersSent) {\n res.status(err.status || 500).json({\n error: {\n name: err.name,\n message: err.message,\n // We don't send the full formatted error to the client for security, \n // but we provide the basic info.\n },\n });\n }\n };\n}\n"],"mappings":";AAAA,OAAO,WAAW;;;ACAlB,YAAY,sBAAsB;AAW3B,SAAS,WAAW,OAAkC;AAC3D,MAAI,CAAC,MAAM,MAAO,QAAO,CAAC;AAE1B,QAAM,SAA0B,uBAAM,MAAM,KAAK;AAEjD,SAAO,OAAO,IAAI,WAAS;AACzB,UAAM,OAAO,MAAM,QAAQ;AAI3B,UAAM,iBACJ,KAAK,WAAW,OAAO,KACvB,KAAK,WAAW,WAAW,KAC3B,CAAC,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,SA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