
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@smarterservices/error-response
Advanced tools
This module is used to format the error and send user defined error in response.
terminal in your project root directory.npm install to install necessary dependencies.config/errors subdirectory, list errors in defined-erros.json in following structure{
"JOI": {
"ERROR_NAME": {
"code": "4000",
"message": "Joi related error message"
}
},
"ERROR_NAME": {
"code": "6000",
"message": "The error message to attach"
}
}
All joi related errors will be listed under JOI object and other general errors will be listed as shown in the structure.
config subdirectory and modify the following things in configuration file (i.e default.json).
url to attach additional url in ResponseprintError to true if you want to print error from moduleFor example, your configuration may look like as follows:
{
"errorResponse": {
"url": "https://www.smarterservices.com/errors/",
"printError": false
}
}
formatError to format the errorconst errorResponse = require('error-response');
const options = {
values: {
approvalSid: 'AP...',
installSid: 'AI...'
}
};
const error = errorResponse.formatError('APPROVAL_NOT_FOUND_UNDER_INSTALL', options);
To generate the above error, the error object should be as follows
{
"APPROVAL_NOT_FOUND_UNDER_INSTALL": {
"code": "6001",
"message": "approval '%approvalSid%' not found under '%installSid%'",
"status": 404
}
}
approvalSid will be replaced by the given in options object.statusCode is 400, passing status in error object will override the default statusCode.errorResponse.failAction to wrap joi related error.n/a
n/a
n/a
FAQs
This is a module to format error
We found that @smarterservices/error-response 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
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.