Reputation: 3148
How can we return a specific error code from plumber R API?
We would like to return a 400 status code with a message, e.g. "Feature x is missing.". We read the plumber documentation but could not figure this out.
If we use stop()
a 500 Internal Server Error is returned with no specific message.
#' predict
#' @param x Input feature
#'
#' @get /predict
function(x) {
if (is.na(x)) {
# error code 400 should be returned
}
# ... # else continue with prediction
}
Upvotes: 3
Views: 3168