Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@smithy/service-error-classification
Advanced tools
[![NPM version](https://img.shields.io/npm/v/@smithy/service-error-classification/latest.svg)](https://www.npmjs.com/package/@smithy/service-error-classification) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/service-error-classification.svg)](h
@smithy/service-error-classification is an npm package designed to help classify and handle service errors in a structured and consistent manner. It provides utilities to identify different types of errors, such as client errors, server errors, and throttling errors, and allows developers to handle these errors appropriately in their applications.
Classify Client Errors
This feature allows you to classify whether an error is a client error (4xx status codes). The code sample demonstrates how to use the `isClientError` function to check if an error is a client error.
const { isClientError } = require('@smithy/service-error-classification');
const error = { statusCode: 400 };
if (isClientError(error)) {
console.log('This is a client error.');
}
Classify Server Errors
This feature allows you to classify whether an error is a server error (5xx status codes). The code sample demonstrates how to use the `isServerError` function to check if an error is a server error.
const { isServerError } = require('@smithy/service-error-classification');
const error = { statusCode: 500 };
if (isServerError(error)) {
console.log('This is a server error.');
}
Classify Throttling Errors
This feature allows you to classify whether an error is a throttling error (typically 429 status code). The code sample demonstrates how to use the `isThrottlingError` function to check if an error is a throttling error.
const { isThrottlingError } = require('@smithy/service-error-classification');
const error = { statusCode: 429 };
if (isThrottlingError(error)) {
console.log('This is a throttling error.');
}
The `http-errors` package is used to create HTTP errors for use in Express and other web frameworks. It provides a simple way to create error objects with HTTP status codes and messages. Unlike @smithy/service-error-classification, it focuses on creating errors rather than classifying them.
The `axios` package is a popular HTTP client for making requests. It includes built-in error handling that can classify errors based on HTTP status codes. While it provides some similar functionality to @smithy/service-error-classification, its primary focus is on making HTTP requests rather than error classification.
The `boom` package is used to create HTTP-friendly error objects. It is often used with the Hapi.js framework but can be used with any Node.js application. It provides utilities to create errors with specific status codes and messages, similar to @smithy/service-error-classification, but it does not focus on classifying existing errors.
FAQs
[![NPM version](https://img.shields.io/npm/v/@smithy/service-error-classification/latest.svg)](https://www.npmjs.com/package/@smithy/service-error-classification) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/service-error-classification.svg)](h
The npm package @smithy/service-error-classification receives a total of 13,810,245 weekly downloads. As such, @smithy/service-error-classification popularity was classified as popular.
We found that @smithy/service-error-classification demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.