funny-error-excuse 1.0.0 β 1.0.1
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/README.md +46 -44
- package/index.js +48 -0
- package/package.json +5 -7
- package/test/index.html +18 -0
- package/test/test-node.js +7 -0
- package/src/browser.js +0 -11
- package/src/core.js +0 -23
- package/src/index.js +0 -5
- package/src/node.js +0 -11
- package/test-node.js +0 -10
- package/test.html +0 -33
package/README.md
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
A lightweight JavaScript npm package that displays funny excuses in the console whenever an error occurs β works in Node.js and Browsers automatically.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Perfect for developers who want debugging with a smile.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
β¨ Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
β
Works in Node.js (terminal)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
β
Works in Browser (console)
|
|
10
|
+
|
|
11
|
+
β
Supports sync & async errors
|
|
12
|
+
|
|
13
|
+
β
Zero configuration
|
|
14
|
+
|
|
15
|
+
β
No ES modules headache
|
|
16
|
+
|
|
17
|
+
β
Works with Vanilla JS, MERN, React, Vite, Webpack
|
|
18
|
+
|
|
19
|
+
π¦ Installation
|
|
10
20
|
npm install funny-error-excuse
|
|
11
|
-
```
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
π Usage
|
|
23
|
+
π’ Node.js / Backend
|
|
24
|
+
require("funny-error-excuse");
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
// trigger an error
|
|
27
|
+
undefinedVariable + 1;
|
|
16
28
|
|
|
17
|
-
### Browser (Vanilla JS / React / MERN frontend)
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
<script type="module">
|
|
21
|
-
import 'funny-error-excuse';
|
|
22
|
-
</script>
|
|
23
|
-
```
|
|
30
|
+
β‘οΈ Whenever an error happens, a random funny excuse will be logged in the terminal.
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
* Random funny excuses will appear whenever an error occurs.
|
|
32
|
+
π Browser / Frontend
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
If you are using a bundler (React, Vite, Webpack):
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
import "funny-error-excuse";
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Thatβs it.
|
|
40
|
+
Errors will automatically show funny excuses in the browser console.
|
|
41
|
+
|
|
42
|
+
π Direct Browser Testing (No Bundler)
|
|
43
|
+
<script src="node_modules/funny-error-excuse/index.js"></script>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
undefinedFunction();
|
|
47
|
+
Promise.reject("Async error test");
|
|
48
|
+
</script>
|
|
34
49
|
|
|
35
|
-
// Trigger some test errors
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
undefinedVariable + 1;
|
|
38
|
-
Promise.reject("Test async error");
|
|
39
|
-
}, 0);
|
|
40
|
-
```
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
Open DevTools β Console π
|
|
52
|
+
π€ Use Cases
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
Debugging without frustration
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
Developer tools
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
π₯ Excuse: It works on my machine!
|
|
50
|
-
ReferenceError: undefinedVariable is not defined
|
|
51
|
-
π₯ Excuse: The code is tired, try again later.
|
|
52
|
-
Unhandled rejection: Test async error
|
|
53
|
-
```
|
|
58
|
+
Fun logging in side projects
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
Developer mood booster π
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
π License
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
* One-line import sets up all hooks automatically
|
|
61
|
-
* Designed for both frontend and backend projects
|
|
62
|
-
* Perfect for adding humor to your development workflow
|
|
64
|
+
MIT License
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
β€οΈ Author
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
Made with β and bugs by Piyush.
|
package/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
const excuses = [
|
|
3
|
+
"Itβs not a bug, itβs a surprise feature π",
|
|
4
|
+
"But It works on my machine π€·ββοΈ",
|
|
5
|
+
"Blame the intern (there is no intern).",
|
|
6
|
+
"Cosmic rays flipped a bit, not my fault.",
|
|
7
|
+
"The code is innocent until proven guilty.",
|
|
8
|
+
"JavaScript decided to freestyle today.",
|
|
9
|
+
"This error was sponsored by caffeine shortage β",
|
|
10
|
+
"It ran fine yesterday, promise.",
|
|
11
|
+
"User clicked too confidently."
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function randomExcuse() {
|
|
15
|
+
return excuses[Math.floor(Math.random() * excuses.length)];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function logExcuse(error) {
|
|
19
|
+
console.log(
|
|
20
|
+
"%cπ₯",
|
|
21
|
+
"color:red; font-weight:bold;"
|
|
22
|
+
);
|
|
23
|
+
console.log(randomExcuse());
|
|
24
|
+
if (error) console.error(error);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// π’ NODE ENVIRONMENT
|
|
28
|
+
if (typeof process !== "undefined" && process.on) {
|
|
29
|
+
process.on("uncaughtException", (err) => {
|
|
30
|
+
logExcuse(err);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
process.on("unhandledRejection", (reason) => {
|
|
34
|
+
logExcuse(reason);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// π BROWSER ENVIRONMENT
|
|
39
|
+
if (typeof window !== "undefined") {
|
|
40
|
+
window.onerror = function (msg, src, line, col, err) {
|
|
41
|
+
logExcuse(err || msg);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
window.addEventListener("unhandledrejection", function (event) {
|
|
45
|
+
logExcuse(event.reason);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "funny-error-excuse",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"keywords": ["funny", "errors", "javascript", "node", "browser", "developer"],
|
|
9
|
-
"author": "Piyush Kumar",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Shows funny excuses in console on every error (Node & Browser)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"keywords": ["error", "funny", "debug", "console"],
|
|
7
|
+
"author": "Piyush",
|
|
10
8
|
"license": "MIT"
|
|
11
9
|
}
|
package/test/index.html
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Funny Error Excuse Test</title>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h1>Open Console</h1>
|
|
8
|
+
|
|
9
|
+
<script src="../index.js"></script>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
undefinedFunction();
|
|
14
|
+
Promise.reject("Browser async error");
|
|
15
|
+
}, 100);
|
|
16
|
+
</script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
package/src/browser.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getRandomExcuse } from './core.js';
|
|
2
|
-
|
|
3
|
-
window.addEventListener('error', (e) => {
|
|
4
|
-
console.error("π₯", getRandomExcuse());
|
|
5
|
-
console.error(e.message);
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
window.addEventListener('unhandledrejection', (e) => {
|
|
9
|
-
console.error("π₯", getRandomExcuse());
|
|
10
|
-
console.error(e.reason);
|
|
11
|
-
});
|
package/src/core.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const excuses = [
|
|
2
|
-
"It works on my machine.",
|
|
3
|
-
"This bug is a feature in disguise.",
|
|
4
|
-
"The code is tired, try again later.",
|
|
5
|
-
"Quantum fluctuation detected.",
|
|
6
|
-
"Blame the intern (just kidding).",
|
|
7
|
-
"The compiler is on vacation today.",
|
|
8
|
-
"Did you turn it off and on again?",
|
|
9
|
-
"This bug was handcrafted with love.",
|
|
10
|
-
"Aliens must have changed the code.",
|
|
11
|
-
"Gravity is messing with your variables.",
|
|
12
|
-
"The error only exists when humans are watching.",
|
|
13
|
-
"The code is just shy, itβll work tomorrow.",
|
|
14
|
-
"I swear this worked in my dreams.",
|
|
15
|
-
"This is a feature in stealth mode.",
|
|
16
|
-
"Your keyboard typed faster than the code could keep up."
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export function getRandomExcuse() {
|
|
20
|
-
const index = Math.floor(Math.random() * excuses.length);
|
|
21
|
-
return excuses[index];
|
|
22
|
-
}
|
|
23
|
-
|
package/src/index.js
DELETED
package/src/node.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getRandomExcuse } from './core.js';
|
|
2
|
-
|
|
3
|
-
process.on('uncaughtException', (err) => {
|
|
4
|
-
console.error("π₯ Excuse:", getRandomExcuse());
|
|
5
|
-
console.error(err.message);
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
process.on('unhandledRejection', (reason) => {
|
|
9
|
-
console.error("π₯ Excuse:", getRandomExcuse());
|
|
10
|
-
console.error(reason);
|
|
11
|
-
});
|
package/test-node.js
DELETED
package/test.html
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Funny Error Excuse Test</title>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<h1>Funny Error Excuse Test</h1>
|
|
9
|
-
<p>Open the console to see funny excuses on errors.</p>
|
|
10
|
-
|
|
11
|
-
<script type="module">
|
|
12
|
-
import './src/index.js';
|
|
13
|
-
|
|
14
|
-
// Helper function to trigger test errors
|
|
15
|
-
function triggerErrors() {
|
|
16
|
-
// Sync error
|
|
17
|
-
try {
|
|
18
|
-
undefinedFunction();
|
|
19
|
-
} catch(e) {
|
|
20
|
-
console.error(e);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Async error
|
|
24
|
-
Promise.reject("Browser async test error π");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Delay to ensure hooks attach
|
|
28
|
-
window.addEventListener('load', () => {
|
|
29
|
-
setTimeout(triggerErrors, 100);
|
|
30
|
-
});
|
|
31
|
-
</script>
|
|
32
|
-
</body>
|
|
33
|
-
</html>
|