* Creates a NetworkError from a platform HttpClientError whose reason is a * request error, keeping the HttpClientError as `cause`. * * **Example** (Creating a network error from an HTTP client error) * * ```ts import.meta.vitest * import { AiError } from "effect/ai" * import {
(
error: HttpClientError.HttpClientError & { readonly reason: HttpClientError.RequestError }
)
| 181 | * @since 4.1.0 |
| 182 | */ |
| 183 | static fromHttpClientError( |
| 184 | error: HttpClientError.HttpClientError & { readonly reason: HttpClientError.RequestError } |
| 185 | ): NetworkError { |
| 186 | return new NetworkError({ |
| 187 | description: error.reason.description, |
| 188 | reason: error.reason._tag, |
| 189 | method: error.reason.request.method, |
| 190 | url: error.reason.request.url, |
| 191 | cause: error |
| 192 | }) |
| 193 | } |
| 194 | |
| 195 | override get message(): string { |
| 196 | const methodAndUrl = `${this.method} ${this.url}` |
no outgoing calls