Skip to content

Commit

Permalink
tryCatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jrosell committed Aug 5, 2024
1 parent 81fde04 commit 1e0b527
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/ambhtmx.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ ambhtmx_app <- \(
#' @param page_title the title tag contents of the page
#' @param head_tags optional htmltools object of the head of the html page
#' @returns the rendered html of the full html page with dependencies
#' @details It can throw exceptions, so handling exceptions is recommended, if not a must.
#' @export
render_page <- \(main = NULL, page_title = NULL, head_tags = NULL) {
penv <- rlang::env_parent()
Expand Down Expand Up @@ -315,8 +316,14 @@ render_page <- \(main = NULL, page_title = NULL, head_tags = NULL) {
#' @param main htmltools object of the body of the html page
#' @param ... other paramters to the render page function
#' @export
send_page <- \(main, res, ...) {
html <- render_page(main = main, ...)
send_page <- \(main, res, ...) {
html <- "Sorry. The system can't render the page as expected."
tryCatch(
expr = {
html <- render_page(main = main, ...)
},
error = \(e) print(e)
)
res$send(html)
}

Expand Down

0 comments on commit 1e0b527

Please sign in to comment.