Errors in ui function should get stack traces

This commit is contained in:
Joe Cheng
2015-11-16 12:46:22 -08:00
parent adc5c8e37a
commit 5c3ac75b34
5 changed files with 61 additions and 4 deletions

View File

@@ -116,10 +116,13 @@ uiHttpHandler <- function(ui, uiPattern = "^/$") {
showcaseMode <- mode
}
uiValue <- if (is.function(ui)) {
if (length(formals(ui)) > 0)
ui(req)
else
ui()
if (length(formals(ui)) > 0) {
# No corresponding ..stacktraceoff.., this is pure user code
..stacktraceon..(ui(req))
} else {
# No corresponding ..stacktraceoff.., this is pure user code
..stacktraceon..(ui())
}
} else {
ui
}

View File

@@ -0,0 +1,11 @@
Loading required package: shiny
Loading required package: methods
Listening on http://127.0.0.1:8765
Warning: Error in badfunc: boom
Stack trace (innermost first):
41: badfunc [${PWD}/stacktrace3/app.R#4]
40: server [${PWD}/stacktrace3/app.R#12]
1: shiny::runApp [${SHINY}/R/server.R#685]
Error in badfunc() : boom
NULL

View File

@@ -0,0 +1,15 @@
library(shiny)
badfunc <- function() {
stop("boom")
}
ui <- fluidPage(
)
server <- function(input, output, session) {
on.exit(stopApp())
badfunc()
}
shinyApp(ui, server)

View File

@@ -0,0 +1,11 @@
Loading required package: shiny
Loading required package: methods
Listening on http://127.0.0.1:8765
Warning: Error in badfunc: boom
Stack trace (innermost first):
37: badfunc [${PWD}/stacktrace4/app.R#4]
36: ui [${PWD}/stacktrace4/app.R#9]
1: shiny::runApp [${SHINY}/R/server.R#685]
Error in badfunc() : boom
NULL

View File

@@ -0,0 +1,17 @@
library(shiny)
badfunc <- function() {
stop("boom")
}
ui <- function(req) {
stopApp()
badfunc()
}
server <- function(input, output, session) {
on.exit(stopApp())
badfunc()
}
shinyApp(ui, server)