DefaultErrorBodyStrategy
public struct DefaultErrorBodyStrategy : ResponseErrorBodyDecodingStrategy
A default strategy for validating error response bodies.
The DefaultErrorBodyStrategy
struct provides a default strategy for validating error response bodies
by checking if the status code is greater than or equal to 400 (Bad Request).
Example usage:
@ResponseErrorBodyWrapper<Body, DefaultErrorBodyStrategy> var body: Body
-
Determines if the given status code represents an error.
This method checks if the provided status code is greater than or equal to the HTTP status code for a bad request (400).
Example usage:
let isError = DefaultErrorBodyStrategy.isError(statusCode: 404) print(isError) // Prints: true
Declaration
Swift
public static func isError(statusCode: Int) -> Bool
Parameters
statusCode
The status code to check.
Return Value
true
if the status code represents an error,false
otherwise.