diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc
index f2eb3f80daeea3aef18ecb0bdd65fa950430071b..99cc8ad9bf098ba5d3311f8de79b478bf777b4ea 100644
--- a/mex/sources/k_order_perturbation/k_order_perturbation.cc
+++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2014 Dynare Team
+ * Copyright (C) 2008-2017 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -347,6 +347,10 @@ extern "C" {
         strstrm << "dynare:k_order_perturbation: Caught general exception: " << e.message();
         DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str());
       }
+    catch (...)
+      {
+        DYN_MEX_FUNC_ERR_MSG_TXT("dynare:k_order_perturbation: Caught undefined exception.");
+      }
     plhs[0] = mxCreateDoubleScalar(0);
   } // end of mexFunction()
 } // end of extern C