SwiftlyRestError

public enum SwiftlyRestError : Error, Equatable, Sendable

Represents errors that can occur when making REST API requests using SwiftlyRest.

Each case corresponds to a specific error scenario, including HTTP status codes, network issues, and unexpected responses.

  • The provided URL is invalid.

    Declaration

    Swift

    case invalidURL(_: String)

    Parameters

    url

    The invalid URL string that caused the error.

  • No response was received from the server.

    Declaration

    Swift

    case noResponse(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The server returned a bad request (400) with an optional message.

    Declaration

    Swift

    case badRequest(_: String, headers: [String : String] = [:], body: String? = nil, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • The request was unauthorized (401).

    Declaration

    Swift

    case unauthorized(_: String, headers: [String : String] = [:], body: String? = nil, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • The request was forbidden (403).

    Declaration

    Swift

    case forbidden(_: String, headers: [String : String] = [:], body: String? = nil, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • The requested resource was not found (404).

    Declaration

    Swift

    case notFound(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The server encountered an internal error (500).

    Declaration

    Swift

    case internalServerError(_: String, headers: [String : String] = [:], body: String? = nil, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • The server returned a bad gateway error (502).

    Declaration

    Swift

    case badGateway(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The service is unavailable (503).

    Declaration

    Swift

    case serviceUnavailable(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The request timed out (408).

    Declaration

    Swift

    case timeout(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The request timed out (504).

    Declaration

    Swift

    case gatewayTimeout(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • The response format was unexpected or could not be parsed.

    Declaration

    Swift

    case unexpectedResponseFormat(_: String, headers: [String : String] = [:], body: String? = nil, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • An unknown error occurred, with code and message.

    Declaration

    Swift

    case unknown(_: String, headers: [String : String] = [:], body: String? = nil, code: Int, response: String = "")

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

    response

    The response body from the server, if available.

  • The request body was invalid or could not be encoded.

    Declaration

    Swift

    case badRequestBody(_: String, headers: [String : String] = [:], body: String? = nil)

    Parameters

    url

    The URL that was requested.

    headers

    The headers sent with the request.

    body

    The body of the request, if any.

  • Compares two SwiftlyRestError values for equality.

    Declaration

    Swift

    public static func == (lhs: SwiftlyRestError, rhs: SwiftlyRestError) -> Bool