funny-error-excuse 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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Funny Error Excuse πŸ˜„
2
+
3
+ Automatically logs a funny excuse in the console whenever a JavaScript error occurs. Works in both browser and Node environments.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install funny-error-excuse
11
+ ```
12
+
13
+ ---
14
+
15
+ ## Usage
16
+
17
+ ### Browser (Vanilla JS / React / MERN frontend)
18
+
19
+ ```html
20
+ <script type="module">
21
+ import 'funny-error-excuse';
22
+ </script>
23
+ ```
24
+
25
+ * Open your browser console and trigger some errors.
26
+ * Random funny excuses will appear whenever an error occurs.
27
+
28
+ ### Node / Express / MERN backend
29
+
30
+ ```js
31
+ import 'funny-error-excuse';
32
+ // or
33
+ require('funny-error-excuse');
34
+
35
+ // Trigger some test errors
36
+ setTimeout(() => {
37
+ undefinedVariable + 1;
38
+ Promise.reject("Test async error");
39
+ }, 0);
40
+ ```
41
+
42
+ * Sync and async errors will log a random funny excuse.
43
+
44
+ ---
45
+
46
+ ## Example Output
47
+
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
+ ```
54
+
55
+ ---
56
+
57
+ ## Notes
58
+
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
63
+
64
+ ---
65
+
66
+ Enjoy coding with a smile! 😎
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
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",
10
+ "license": "MIT"
11
+ }
package/src/browser.js ADDED
@@ -0,0 +1,11 @@
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 ADDED
@@ -0,0 +1,23 @@
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 ADDED
@@ -0,0 +1,5 @@
1
+ if (typeof window !== 'undefined') {
2
+ import('./browser.js');
3
+ } else if (typeof process !== 'undefined') {
4
+ import('./node.js');
5
+ }
package/src/node.js ADDED
@@ -0,0 +1,11 @@
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 ADDED
@@ -0,0 +1,10 @@
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 ADDED
@@ -0,0 +1,33 @@
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>