-
Notifications
You must be signed in to change notification settings - Fork 0
Enhancers: IdentifiersEnhancer
File: identifiers.enhancer.ts
The IdentifiersEnhancer class is a part of the error-enhanced library designed to augment error objects with unique identifiers, custom error codes, and additional metadata. This class is particularly beneficial for in-depth error analysis in large-scale applications.
| Property | Description |
|---|---|
id |
A unique identifier (UUID) for the error object, auto-generated upon instantiation. |
errorCode |
A custom error code, default is -1. |
errorCodePrefix |
A prefix for the error code, default is an empty string. |
errorDescription |
A human-readable description of the error code, default is an empty string. |
timestamp |
A Unix timestamp representing when the error object was instantiated, default is -1. |
severity |
Severity level of the error, defaults to Severity.MEDIUM. |
category |
Category to which the error belongs, defaults to Category.UNKNOWN. |
Sets the custom error code. Validates if it's a number.
Usage Example:
const error = new IdentifiersEnhancer();
error.setErrorCode(400);Sets the error code prefix. Validates if it's a valid string.
Usage Example:
error.setErrorCodePrefix("ERR");Sets a human-readable description for the error code. Validates if it's a valid string.
Usage Example:
error.setErrorDescription("Bad Request");Sets the error's severity level. Validates against the Severity enum.
Usage Example:
error.setSeverity(Severity.HIGH);Sets the error's category. Validates against the Category enum.
Usage Example:
error.setCategory(Category.SYSTEM);Calculates a hash value for the error object based on its properties.
Usage Example:
const hash = error.getHash();- Audit & Logging: This class is useful for attaching additional metadata to errors, aiding in more effective error tracking in logging systems.
- Error Analysis: The extra information provided can be helpful for in-depth error analysis.
error-enhanced Wiki
Version: 1.2.1 - © 2023
🔗 MIT License | 📦 GitHub Repository | 🐞 Report Issues | ✉️ Contact