
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@loves/loves-web-error-handler
Advanced tools
A library to format errors as JSON to send back to web clients based on where the application is running.
npm install @loves/loves-web-error-handler
Creates consistent web api errors in the format:
{
statusCode: 500,
errorCode: '',
message: '',
errors: [
{
field: '',
message: ''
}
]
}
const lovesErrorHandler = require('@loves/loves-web-error-handler');
formatError(err)
-- Converts Error object to above. Retains all above fields if provided.
badRequest(message, errorCode)
-- Creates a 400 with customizable error messaging (Default: 'Invalid request.')
resourceNotFound(message, errorCode)
-- Creates a 404 with customizable error messaging (Default: 'The requested resource could not be found.')
internalServerError(message, errorCode)
-- Creates a 500 with customizable error messaging (Default: 'An error has occurred.')
unauthorized(message, errorCode)
-- Creates a 401 with customizable error messaging (Default: 'Access is denied due to invalid credentials.')
validationError(message, errorCode)
-- Creates a 422 with customizable error messaging (Default: 'Form validation failed.')
addValidationError(err, field, message)
-- Appends field level validation error messaging to existing error object.
FAQs
A web error handler that formats responses.
The npm package @loves/loves-web-error-handler receives a total of 1 weekly downloads. As such, @loves/loves-web-error-handler popularity was classified as not popular.
We found that @loves/loves-web-error-handler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.