Skip to content

Commit

Permalink
Errors in ui function should get stack traces
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheng5 committed Nov 16, 2015
1 parent adc5c8e commit 5c3ac75
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/shinyui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 11 additions & 0 deletions smoketests/stacktrace3/R.out.save
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions smoketests/stacktrace3/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
library(shiny)

badfunc <- function() {
stop("boom")
}

ui <- fluidPage(
)

server <- function(input, output, session) {
on.exit(stopApp())
badfunc()
}

shinyApp(ui, server)
11 changes: 11 additions & 0 deletions smoketests/stacktrace4/R.out.save
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions smoketests/stacktrace4/app.R
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5c3ac75

Please sign in to comment.