Effortlessly decode cryptic error messages into clear, actionable insights with human-readable-errors! Designed for developers, this library helps you identify the root causes of errors, suggests practical solutions, and even educates you on debugging strategies.
- Languages:
- JavaScript (General, Node.js, React)
- Python (General, Django)
- Java (General, Spring)
- Automatically detects the programming language and framework based on the error message.
- Analyzes error messages and stack traces to extract valuable debugging information.
- Provides structured insights into the type, cause, and severity of errors.
- Extensive mappings of common errors with:
- Detailed descriptions
- Likely causes
- Tested solutions
- Example code snippets
- Links to official documentation and resources
- Unrecognized errors are automatically added as "rowErrors."
- Row errors are indexed and incorporated into the main database within 24 hours.
- Utilizes string similarity algorithms to find the best match for your error.
- Outputs a match score, reflecting the confidence level of the suggested solution.
- Easily extendable to include new languages, frameworks, and error mappings.
- Designed for scalability, maintainability, and performance.
Install the library via npm:
npm install human-readable-errorsconst { handleError } = require("human-readable-errors");
const errorString = "TypeError: Cannot read property 'length' of undefined";
handleError(errorString)
.then((errorDetails) => {
console.log(errorDetails);
})
.catch((err) => {
console.error(err);
});const { handlePrettyError } = require("human-readable-errors");
const errorString = "ReferenceError: x is not defined";
handlePrettyError(errorString)
.then((prettyError) => {
console.log(prettyError);
})
.catch((err) => {
console.error(err);
});You can initialize global error handling for browser or Node.js environments using:
const { initializeHumanReadableErrors } = require("human-readable-errors");
initializeHumanReadableErrors();Endpoint: POST /errors/search
Search for errors using fuzzy search capabilities.
Request Body:
{
"query": "SyntaxError: Unexpected token"
}Response Example:
[
{
"id": "12345",
"language": "JavaScript",
"type": "Error",
"error": "SyntaxError: Unexpected token",
"description": "An unexpected token is encountered during parsing.",
"cause": ["Missing closing bracket", "Unescaped special character"],
"solution": [
"Check the syntax around the reported token",
"Ensure special characters are properly escaped"
]
}
]We welcome contributions to improve the library! Whether it's adding new error mappings, enhancing features, or fixing bugs, check out our CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License. See the LICENSE file for details.
Have a question or suggestion? Feel free to:
- Open an issue on GitHub.
- Share your thoughts with the community!
const {
handleError,
handlePrettyError,
initializeHumanReadableErrors,
initializeNodeErrorHandler,
initializeBrowserErrorHandler,
} = require("human-readable-errors");
// Initialize global error handling
initializeHumanReadableErrors();
// Handle an error and get detailed output
handleError("TypeError: Cannot read property 'foo' of undefined")
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
// Pretty print error details
handlePrettyError("ReferenceError: bar is not defined")
.then((formattedError) => {
console.log(formattedError);
})
.catch((error) => {
console.error(error);
});