diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc
index 90f132349437d472d22d7b8ad4fb15556723acb4..4cc505f28627fc57ba262cd46ebd458c7ad1bf30 100644
--- a/preprocessor/DynamicModel.cc
+++ b/preprocessor/DynamicModel.cc
@@ -1745,7 +1745,7 @@ DynamicModel::writeSetState(const string &mat) const
       }
 
   mOutputFile << "    otherwise" << endl
-              << "        error('" << fname << ": should not arrive here');" << endl
+              << "        error(['" << fname << ": should not arrive here. State passed was ' state]);" << endl
               << "end" << endl
               << "end" << endl;
   mOutputFile.close();