I have my API built using plumber. When I run it in R Workbench the error code returns with the correct message. But when the same API reployed in RConnect, doesn't return the message.
Error message when the app is run in Workbench during dev:
{
"error": "500 - Internal server error",
"message": "Error in value[[3L]](cond): nanodbc/nanodbc.cpp:1655: 00000: INSERT 1: The transition 13 > 13 is not allowed. Please contact System Admin., \n<SQL> 'EXEC\t[dbo].[sp_*******]\n"
}
Error message when the app is run in RConnect in Production:
{
"error": "500 - Internal server error"
}
Repex showing my decorated function and how I am error catching:
#* @apiTitle My API
#* @apiDescription This is a Repex
#*
#* #* Run SP
#* @param myParam
#* @post /run_sp
function(myParam){
# Trycatching the ruinning of the sp
tryCatch(
expr =
{
result <- dbGetQuery(mydb, paste0("EXEC [dbo].[my_sp] @myParam = ", myParam,))
return(result)
},
error = function(e) {
warning(e$message)
stop(e$message)
})
dbDisconnect(mydb)
}
#* @plumber
function(pr) {
pr %>%
# Overwrite the default serializer to return unboxed JSON
pr_set_serializer(serializer_unboxed_json())
}