Identifiers
File: identifiers.interface.ts
Introduction
The Identifiers
interface serves as the backbone for adding identification metadata to your enhanced Error objects. It includes properties for unique identifiers, error codes, timestamps, and categories, making it easier to track, log, and categorize errors.
Properties
Property | Type | Description |
---|---|---|
|
| A read-only unique identifier for each error instance. |
|
| A read-only error code that provides more details on the error. |
|
| A read-only prefix for the error code. |
|
| A read-only description of the error. |
|
| A read-only Unix timestamp for the error. |
|
| A read-only high-precision timestamp. |
|
| A read-only field for the error's severity. |
|
| A read-only field for the error's category. |
Methods
Method | Return Type | Description |
---|---|---|
|
| Set the error code. Allows for method chaining. |
|
| Set the error code prefix. Allows for method chaining. |
|
| Set the error description. Allows for method chaining. |
|
| Generate a hash based on the error's unique properties. |
|
| Set the severity level. Allows for method chaining. |
|
| Set the category for the error. Allows for method chaining. |
Example Usage
Best Practices
Prefer setting the error code and severity as soon as the error object is initialized.
Use the
getHash()
method for error deduplication in logging or analytics.
Conclusion
The Identifiers
interface plays a vital role in error tracking and categorization. By understanding its properties and methods, you'll be better equipped to manage errors effectively.