From d9e330c4a4786b82ffcae81a9446349efc490f72 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.priv>
Date: Wed, 6 Mar 2019 08:33:06 +0100
Subject: [PATCH] v1.2.7.8 CLEAN: Calibration returns an error when FUN_CALIB
 is not a function

---
 DESCRIPTION     | 4 ++--
 NEWS.rmd        | 4 +++-
 R/Calibration.R | 7 ++++++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index a004ffb1..9a8c48de 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: airGR
 Type: Package
 Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
-Version: 1.2.7.7
-Date: 2019-03-04
+Version: 1.2.7.8
+Date: 2019-03-06
 Authors@R: c(
   person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
   person("Charles", "Perrin", role = c("aut", "ths"), comment = c(ORCID = "0000-0001-8552-1881")),
diff --git a/NEWS.rmd b/NEWS.rmd
index 2d514bcc..f913f1db 100644
--- a/NEWS.rmd
+++ b/NEWS.rmd
@@ -13,7 +13,7 @@ output:
 
 
 
-### 1.2.7.7 Release Notes (2019-03-04) 
+### 1.2.7.8 Release Notes (2019-03-06) 
 
 
 
@@ -38,6 +38,8 @@ output:
 
 - <code>CreateRunOptions()</code> now presents a <code>warnings</code> argument to replace the verbose action (the <code>verbose</code> argument is keep to print messages).
 
+- <code>Calibration()</code> function now returns an error message if <code>FUN_CALIB</code> is not a function
+
 
 #### Major user-visible changes
 
diff --git a/R/Calibration.R b/R/Calibration.R
index f0d4aff1..162fd7d7 100644
--- a/R/Calibration.R
+++ b/R/Calibration.R
@@ -1,4 +1,9 @@
-Calibration <- function(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel, FUN_TRANSFO = NULL, verbose = TRUE) {
+Calibration <- function(InputsModel, RunOptions, InputsCrit, CalibOptions,
+                        FUN_MOD, FUN_CRIT, FUN_CALIB = Calibration_Michel, FUN_TRANSFO = NULL,
+                        verbose = TRUE) {
+  if (! is.function(FUN_CALIB)) {
+    stop("'FUN_CALIB' must be a function")
+  }
   return(FUN_CALIB(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD, FUN_CRIT, FUN_TRANSFO, verbose = verbose))
 }
 
-- 
GitLab