Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@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
The npm package @smarterservices/error-response receives a total of 2 weekly downloads. As such, @smarterservices/error-response popularity was classified as not popular.
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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.