Salome HOME
Merge commit 'f709219506b7cd587e94abc5ebed18d629df92d8'
[modules/shaper.git] / src / ParametersAPI / ParametersAPI_Parameter.cpp
index 2af3eec68d1bd59e38dd6436496423c4f77fb9c5..74fef6887028a69ee0558f7b5232e58f81ee7f3e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,7 @@ ParametersAPI_Parameter::ParametersAPI_Parameter(
     const std::shared_ptr<ModelAPI_Feature> & theFeature,
     const std::string & theName,
     const std::string & theExpression,
-    const std::string & theComment)
+    const std::wstring & theComment)
 : ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
@@ -87,10 +87,18 @@ void ParametersAPI_Parameter::dump(ModelHighAPI_Dumper& theDumper) const
 ParameterPtr addParameter(const std::shared_ptr<ModelAPI_Document> & thePart,
                           const std::string & theName,
                           const std::string & theExpression,
-                          const std::string & theComment)
+                          const std::wstring & theComment)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ParametersAPI_Parameter::ID());
-  return ParameterPtr(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment));
+  ParameterPtr aParam(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment));
+
+  if (!aParam->feature()->error().empty())
+  {
+    std::string anError("Error with parameter \"");
+    anError += theName + "\": " + aParam->feature()->error();
+    throw anError;
+  }
+  return aParam;
 }
 
 //--------------------------------------------------------------------------------------