Skip to content

Commit daf7d8f

Browse files
committed
check for non existing path
1 parent 4f3ff0a commit daf7d8f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

R/commonMachineLearningRegression.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@
490490
saveResult <- .mlSaveModelToDisk(options, regressionResult, dataset, class = "jaspRegression")
491491
.mlPossiblyShowSaveResult(table, saveResult, options)
492492

493-
494493
}
495494

496495
.mlAddSaveModelInfo <- function(table, options) {
@@ -533,8 +532,14 @@
533532

534533
if (identical(saveResult[["error"]], "success") && isTRUE(saveResult[["exists"]])) {
535534
table$addFootnote(gettextf("The model is saved as <i>%1$s</i>.", basename(options[["savePath"]])))
536-
} else if (!identical(saveResult[["error"]], "success")) {
537-
table$addFootnote(gettextf("The model could not be saved because the following error occured: %s", saveResult[["error"]][["message"]]))
535+
} else if (isTryError(saveResult[["error"]])) {
536+
msg <- .extractErrorMessage(saveResult[["error"]])
537+
if (grepl(x = msg, pattern = "cannot open the connection", fixed = TRUE) && !dir.exists(dirname(options[["savePath"]]))) {
538+
# likely occurs most often when using a downloaded jasp file that contains a path that is valid another computer
539+
table$addFootnote(gettextf("The model could not be saved because the parent directory '%s' does not exist.", dirname(options[["savePath"]])))
540+
} else
541+
table$addFootnote(gettextf("The model could not be saved because the following error occured: %s", msg))
542+
538543
} else if (!isTRUE(saveResult[["exists"]])) {
539544
table$addFootnote(gettext("The model could not be saved because an unexpected error occured."))
540545
}

0 commit comments

Comments
 (0)