Open jwebbsoma opened 1 year ago
Currently all mounted routers behave pretty independently from their parent router.
For now, you'll need to add the custom behavior manually
#* @plumber
function(pr) {
err_func <- function(req, res, err) {
print(err)
res$status <- 500
list(error = "An error occurred. Please contact your administrator.")
}
data_pr <-
plumb("./controllers/data.R") %>%
pr_set_error(err_func)
pr %>%
pr_mount("/data", data_pr) %>%
pr_get("/simple", function() stop("I'm an error!")) %>%
pr_set_error(err_func) %>%
pr_set_serializer(serializer_unboxed_json(na="null", null="null", force=TRUE, digits=15))
}
If pr_merge()
was implemented, I believe this confusion would go away. Keeping open until pr_merge()
is implemented.
System details
Example application or steps to reproduce the problem
plumber.R:
./controllers/data.R:
Describe the problem in detail
Trying to setup a global error handler and it appears to not be working for any endpoints defined in a mounted file. Running the above plumber code will result in "/simple" and "/trouble" returning the custom error message but "/data/columns" does not. Is there something special I need to be doing for mounted files to be included with the custom error handler?