handleResponse :: (Req.HttpResponse response, Req.HttpResponseBody response ~ ByteString) => response -> Either Error RunResult
handleResponse res =
    let
        body =
            Req.responseBody res
    in
    if isSuccessStatus (Req.responseStatusCode res) then
        Aeson.eitherDecodeStrict' body
            & Bifunctor.first (DecodeSuccessResponseError body)

      else
        case Aeson.eitherDecodeStrict' body of
            Right apiError ->
                Left (ApiError apiError)

            Left decodeError ->
                Left (DecodeErrorResponseError body decodeError)
handleResponse :: (Req.HttpResponse response, Req.HttpResponseBody response ~ ByteString) => response -> Either Error RunResult
handleResponse res =
    let
        body =
            Req.responseBody res
    in
    if isSuccessStatus (Req.responseStatusCode res) then
        Aeson.eitherDecodeStrict' body
            & Bifunctor.first (DecodeSuccessResponseError body)

      else
        case Aeson.eitherDecodeStrict' body of
            Right apiError ->
                Left (ApiError apiError)

            Left decodeError ->
                Left (DecodeErrorResponseError body decodeError)
handleResponse res =
    let
        body =
            Req.responseBody res
    in
    if isSuccessStatus (Req.responseStatusCode res) then
        Aeson.eitherDecodeStrict' body
            & Bifunctor.first (DecodeSuccessResponseError body)

      else
        case Aeson.eitherDecodeStrict' body of
            Right apiError ->
                Left (ApiError apiError)

            Left decodeError ->
                Left (DecodeErrorResponseError body decodeError)