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 CHANGED
@@ -1,66 +1,68 @@
1
- # Funny Error Excuse πŸ˜„
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
- Automatically logs a funny excuse in the console whenever a JavaScript error occurs. Works in both browser and Node environments.
3
+ Perfect for developers who want debugging with a smile.
4
4
 
5
- ---
5
+ ✨ Features
6
6
 
7
- ## Installation
7
+ βœ… Works in Node.js (terminal)
8
8
 
9
- ```bash
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
- ## Usage
26
+ // trigger an error
27
+ undefinedVariable + 1;
16
28
 
17
- ### Browser (Vanilla JS / React / MERN frontend)
18
29
 
19
- ```html
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
- * Open your browser console and trigger some errors.
26
- * Random funny excuses will appear whenever an error occurs.
32
+ 🌐 Browser / Frontend
27
33
 
28
- ### Node / Express / MERN backend
34
+ If you are using a bundler (React, Vite, Webpack):
29
35
 
30
- ```js
31
- import 'funny-error-excuse';
32
- // or
33
- require('funny-error-excuse');
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
- * Sync and async errors will log a random funny excuse.
51
+ Open DevTools β†’ Console πŸ˜„
52
+ 🀝 Use Cases
43
53
 
44
- ---
54
+ Debugging without frustration
45
55
 
46
- ## Example Output
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
- ## Notes
62
+ πŸ“„ License
58
63
 
59
- * Works in Chrome, Firefox, Edge, and Node.js v14+
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
- Enjoy coding with a smile! 😎
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.0",
4
- "type": "module",
5
- "main": "src/index.js",
6
- "browser": "src/browser.js",
7
- "description": "Automatically logs funny excuses in console on errors (Browser + Node).",
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
  }
@@ -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>
@@ -0,0 +1,7 @@
1
+ require("../index.js");
2
+
3
+ // Trigger errors
4
+ setTimeout(() => {
5
+ notDefined + 1;
6
+ Promise.reject("Async test error");
7
+ }, 100);
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
@@ -1,5 +0,0 @@
1
- if (typeof window !== 'undefined') {
2
- import('./browser.js');
3
- } else if (typeof process !== 'undefined') {
4
- import('./node.js');
5
- }
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
@@ -1,10 +0,0 @@
1
- import './src/index.js';
2
-
3
- // Delay to ensure hooks attach
4
- setTimeout(() => {
5
- // Trigger sync error
6
- undefinedVariable + 1;
7
-
8
- // Trigger async error
9
- Promise.reject("Node test error 😎");
10
- }, 0);
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>