HttpStatus
File: http-status.interface.ts
Introduction
The HttpStatus
interface in error-enhanced
focuses on encapsulating HTTP-specific information related to the error. This includes the HTTP status code, URL, and HTTP method, among other properties. The interface allows for a detailed understanding of the error in the context of an HTTP request/response cycle.
Properties
Property | Type | Description |
---|---|---|
|
| A read-only HTTP status code that signifies the nature of the error. |
|
| A read-only URL where the error occurred. |
|
| A read-only HTTP method (GET, POST, PUT, etc.) related to the error. |
Methods
Method | Return Type | Description |
---|---|---|
|
| Sets the HTTP status code. Allows for method chaining. |
|
| Sets the URL. Allows for method chaining. |
|
| Sets the HTTP method. Allows for method chaining. |
|
| Sets request headers. Allows for method chaining. |
|
| Sets response headers. Allows for method chaining. |
|
| Sets query parameters. Allows for method chaining. |
|
| Sets the request body. Allows for method chaining. |
|
| Sets the response body. Allows for method chaining. |
|
| Sets the client IP address. Allows for method chaining. |
|
| Sets the latency in milliseconds. Allows for method chaining. |
Example Usage
Best Practices
Prefer to set all HTTP-related properties as soon as you catch the error, so you capture the most accurate state of the request/response cycle.
Use this interface in conjunction with others like
Identifiers
for a comprehensive error object.
Conclusion
The HttpStatus
interface provides a robust way to capture HTTP-specific information related to errors, making it easier to debug and log errors that occur during API calls or web requests.