MCPcopy Create free account
hub / github.com/Effect-TS/effect / StatusCodeError

Class StatusCodeError

packages/effect/src/http/HttpClientError.ts:319–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317 * @since 4.0.0
318 */
319export class StatusCodeError extends ReasonError("StatusCodeError")<{
320 readonly request: HttpClientRequest.HttpClientRequest
321 readonly response: ClientResponse.HttpClientResponse
322 readonly cause?: unknown
323 readonly description?: string | undefined
324}> {
325 /**
326 * Formats the request method and URL for status code error messages.
327 *
328 * @stability unstable
329 * @since 4.0.0
330 */
331 get methodAndUrl() {
332 return formatMethodAndUrl(this)
333 }
334
335 /**
336 * Builds the status code error message from the response status, optional description, and request details.
337 *
338 * @stability unstable
339 * @since 4.0.0
340 */
341 override get message() {
342 const info = `${this.response.status} ${this.methodAndUrl}`
343 return formatMessage(formatReason(this._tag), this.description, info)
344 }
345
346 override toJSON(): unknown {
347 return reasonToJSON(this, super.toJSON())
348 }
349}
350
351/**
352 * Response error for failures while decoding an HTTP response, including a

Callers

nothing calls this directly

Calls 1

ReasonErrorFunction · 0.85

Tested by

no test coverage detected