Skip to content

Commit f36f473

Browse files
committed
api: add error log for service
1 parent 9f0cf99 commit f36f473

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api/plumber.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ error_handler <- function(req, res, err) {
4747
}
4848

4949
logger::log_info("Listening for requests on ", paste0(host, ":", port))
50-
plumber::pr("api.R") |>
51-
plumber::pr_set_error(error_handler) |>
52-
plumber::pr_run(host = host, port = port, quiet = TRUE)
50+
51+
tryCatch({
52+
plumber::pr("api.R") |>
53+
plumber::pr_set_error(error_handler) |>
54+
plumber::pr_run(host = host, port = port, quiet = TRUE)
55+
}, error = function(cnd) {
56+
logger::log_error("api fatal internal failure: {msg}", msg = cnd$message)
57+
rlang::abort("API Fatal Internal Failure")
58+
})

0 commit comments

Comments
 (0)