Skip to content

Commit 6534a6d

Browse files
author
Sebastian Kopf
committed
descriptive error message in ggsave if device cannot be found from file extension
basically if user tries to ggsave a filename with an unknown extension
1 parent dc370c0 commit 6534a6d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R/save.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ ggsave <- function(filename = default_name(plot), plot = last_plot(),
7575
}
7676

7777
default_device <- function(ext) {
78-
match.fun(ext)
78+
tryCatch(match.fun(ext), error = function(e)
79+
stop(sprintf("Cannot find a graphics device that matches file extension '%s'.", ext)))
7980
}
8081

8182
units <- match.arg(units)

0 commit comments

Comments
 (0)