Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
graceful-error
Advanced tools
GracefulError 在 Node 原生错误对象 Error 的基础之上,新增了 6 个属性,如下所示。
ErrorLevelEnum 错误级别枚举对象,原始定义如下
const ErrorLevelEnum = {
INFO: 'info',
NOTICE: 'notice',
ALERT: 'alert',
WARN: 'warn',
ERROR: 'error',
CRITICAL: 'critical',
};
示例代码:
ErrorLevelEnum.INFO; // 'info'
ErrorLevelEnum.ERROR; // 'error'
参数说明:
示例代码:
const { createError, ErrorLevelEnum } = require('graceful-error');
const err = createError(
{
message: 'Invalid HTTP header value.',
appId: 'demo',
logIndex: 'demo_log_index',
code: 'ERR_HTTP_INVALID_HEADER_VALUE',
level: ErrorLevelEnum.ERROR,
feature: 'demo_feature',
},
{
foo: 'bar',
}
);
将一个错误对象包装成 GracefulError 类型的错误。
参数说明:
const { wrapError } = require('graceful-error');
const oldError = new Error('hello world');
const newError = wrapError(oldError);
将 err 错误对象转换成一个 JSON 对象
const errJSON = err.toJSON();
FAQs
### 一、基础介绍
The npm package graceful-error receives a total of 12 weekly downloads. As such, graceful-error popularity was classified as not popular.
We found that graceful-error demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.