|
| 1 | +# 🎉 Fake Error Generator |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +**`fake-error-generator`** is a lightweight, fun npm package that lets you generate **fake console errors, warnings, logs, and info messages** — perfect for **pranking your friends, demos, or just for laughs**! 😎 |
| 6 | + |
| 7 | +> ⚠️ Note: This package is purely for **fun and educational purposes**. Don’t use it in production for real error handling. |
| 8 | +
|
| 9 | +--- |
| 10 | + |
| 11 | +## 🚀 Features |
| 12 | + |
| 13 | +* Generate **fake errors, warnings, logs, or info messages** |
| 14 | +* Customizable messages, types, count, and delay |
| 15 | +* Randomized messages for maximum fun |
| 16 | +* Works in **Node.js** (and can be bundled for the browser) |
| 17 | +* Lightweight and zero dependencies |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 💿 Installation |
| 22 | + |
| 23 | +```bash |
| 24 | +npm install fake-error-generator |
| 25 | +``` |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## 🧩 Usage |
| 30 | + |
| 31 | +### 1. Generate a single fake error |
| 32 | + |
| 33 | +```js |
| 34 | +const { fakeError } = require("fake-error-generator"); |
| 35 | + |
| 36 | +fakeError({ message: "Something went wrong!", type: "error" }); |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Generate multiple warnings with a delay |
| 40 | + |
| 41 | +```js |
| 42 | +fakeError({ message: "Watch out!", type: "warn", count: 3, delay: 500 }); |
| 43 | +``` |
| 44 | + |
| 45 | +### 3. Generate random fake errors |
| 46 | + |
| 47 | +```js |
| 48 | +const { randomFakeError } = require("fake-error-generator"); |
| 49 | + |
| 50 | +randomFakeError({ |
| 51 | + messages: ["Oops!", "Crash!", "404 Not Found!"], |
| 52 | + count: 5, |
| 53 | + delay: 300 |
| 54 | +}); |
| 55 | +``` |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## 🎨 Message Types |
| 60 | + |
| 61 | +| Type | Console Output | |
| 62 | +| ------- | -------------- | |
| 63 | +| `log` | ✅ Normal log | |
| 64 | +| `warn` | ⚠️ Warning | |
| 65 | +| `error` | ❌ Error | |
| 66 | +| `info` | ℹ️ Info | |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## 😎 Example |
| 71 | + |
| 72 | +```js |
| 73 | +const { fakeError, randomFakeError } = require("fake-error-generator"); |
| 74 | + |
| 75 | +fakeError({ message: "Server failed to respond!", type: "error" }); |
| 76 | +fakeError({ message: "Check your input!", type: "warn", count: 3, delay: 1000 }); |
| 77 | +randomFakeError({ messages: ["Crash!", "Oops!", "Fail!"], count: 5, delay: 500 }); |
| 78 | +``` |
| 79 | + |
| 80 | +Output in console: |
| 81 | + |
| 82 | +``` |
| 83 | +❌ Server failed to respond! |
| 84 | +⚠️ Check your input! |
| 85 | +⚠️ Check your input! |
| 86 | +⚠️ Check your input! |
| 87 | +⚠️ Crash! |
| 88 | +❌ Oops! |
| 89 | +ℹ️ Fail! |
| 90 | +... |
| 91 | +``` |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## 💡 Tips for Fun |
| 96 | + |
| 97 | +* Use in **demo projects** to fake errors for UI testing |
| 98 | +* **Prank friends** with funny “critical errors” |
| 99 | +* Combine with `setInterval` for continuous chaos 😏 |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## 📄 License |
| 104 | + |
| 105 | +MIT License © 2025 Menula De Silva |
| 106 | + |
| 107 | +[](LICENSE) |
| 108 | + |
| 109 | +--- |
0 commit comments