forked from loafle/openapi-generator-original
[R] feat(r): handling error response for 3xx cases (#3571)
* feat(r): handling error response for 3xx cases * fix(r) : changed the message for 3XX case * fix(r) : fixing the status code 3xx
This commit is contained in:
parent
a05f68431a
commit
8cd5a4187b
@ -291,6 +291,22 @@
|
||||
{{! Returning the ApiResponse object with NULL object when the endpoint doesn't return anything}}
|
||||
ApiResponse$new(NULL, resp)
|
||||
{{/returnType}}
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- paste("Server returned " , httr::status_code(resp) , " response status code.")
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
{{/returnExceptionOnFailure}}
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
|
@ -371,6 +371,8 @@ PetApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -417,6 +419,8 @@ PetApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -465,6 +469,8 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -513,6 +519,8 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -565,6 +573,8 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -611,6 +621,8 @@ PetApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -660,6 +672,8 @@ PetApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -715,6 +729,8 @@ PetApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -210,6 +210,8 @@ StoreApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -254,6 +256,8 @@ StoreApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -302,6 +306,8 @@ StoreApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -352,6 +358,8 @@ StoreApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -329,6 +329,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -374,6 +376,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -419,6 +423,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -461,6 +467,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -509,6 +517,8 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -561,6 +571,8 @@ UserApi <- R6::R6Class(
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -595,6 +607,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
@ -647,6 +661,8 @@ UserApi <- R6::R6Class(
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user