funny-error-messages
v1.0.0
Published
A collection of funny and sarcastic error messages to make debugging less painful
Maintainers
Readme
funny-error-messages
A collection of funny and sarcastic error messages to make debugging less painful. This package provides humorous error messages that you can use to lighten the mood during debugging sessions.
Installation
npm install funny-error-messagesUsage
Basic Usage
// ESM
import { getFunnyErrorMessage, createFunnyError } from 'funny-error-messages';
// CommonJS
const { getFunnyErrorMessage, createFunnyError } = require('funny-error-messages');
// Get a funny error message
const message = getFunnyErrorMessage();
console.log(message);
// Example output: "This isn't a bug, it's an undocumented feature. Maybe programming isn't your calling? 🔥"
// Create an Error object with a funny message
try {
throw createFunnyError('syntax');
} catch (error) {
console.error(error.message);
// Example output: "Your syntax looks like a cat walked on your keyboard. Have you tried turning it off and on again? 🤦♂️"
}Error Types
You can specify the type of error message:
// Options: 'generic', 'syntax', 'type', 'runtime'
getFunnyErrorMessage('type');
createFunnyError('runtime');Customization Options
You can customize the messages with these options:
const options = {
sarcastic: true, // Include a sarcastic addon (default: true)
emoji: true, // Include a random emoji (default: true)
positiveSpin: false // Add encouraging message (default: false)
};
getFunnyErrorMessage('generic', options);Advanced Usage
Use the FunnyErrorMessages class directly:
import FunnyErrorMessages from 'funny-error-messages';
// Get a message
const message = FunnyErrorMessages.getErrorMessage('syntax', { positiveSpin: true });
// Create an error
const error = FunnyErrorMessages.createError('runtime', { emoji: false });API Reference
Functions
getFunnyErrorMessage(errorType?, options?)- Returns a funny error message stringcreateFunnyError(errorType?, options?)- Returns an Error object with a funny message
Class
FunnyErrorMessages- The main class with static methods
Error Types
'generic'- General error messages'syntax'- Syntax error messages'type'- Type error messages'runtime'- Runtime error messages
Options
sarcastic(boolean) - Include a sarcastic addon (default: true)emoji(boolean) - Include a random emoji (default: true)positiveSpin(boolean) - Add an encouraging message (default: false)
License
MIT
