Commit fd68c636 authored by Tom Perkins's avatar Tom Perkins
Browse files

Re #12247 Change error messages on TypedValue casts

When IPropertyManager::getValue fails to assign the property to the
specified type, a runtime_error is raised. Changed the error messages in
all (specific) cases to specify exactly what type it was expecting,
i.e. (const) shared_ptr<X> not just X or const X.
parent 84470d74
......@@ -1644,8 +1644,8 @@ IPropertyManager::getValue<API::IAlgorithm_sptr>(
if (prop) {
return *prop;
} else {
std::string message =
"Attempt to assign property " + name + " to incorrect type";
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<IAlgorithm>";
throw std::runtime_error(message);
}
}
......@@ -1667,7 +1667,8 @@ IPropertyManager::getValue<API::IAlgorithm_const_sptr>(
return prop->operator()();
} else {
std::string message =
"Attempt to assign property " + name + " to incorrect type";
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<IAlgorithm>";
throw std::runtime_error(message);
}
}
......
......@@ -1245,8 +1245,9 @@ IPropertyManager::getValue<Mantid::API::ExperimentInfo_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected ExperimentInfo.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<ExperimentInfo>.";
throw std::runtime_error(message);
}
}
......@@ -1261,8 +1262,9 @@ IPropertyManager::getValue<Mantid::API::ExperimentInfo_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const ExperimentInfo.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<ExperimentInfo>.";
throw std::runtime_error(message);
}
}
......
......@@ -47,8 +47,9 @@ IPropertyManager::getValue<Mantid::API::IEventWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected IEventWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<IEventWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -63,8 +64,9 @@ IPropertyManager::getValue<Mantid::API::IEventWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const IEventWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<IEventWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -1118,7 +1118,7 @@ IPropertyManager::getValue<boost::shared_ptr<Mantid::API::IFunction>>(
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected IFitFunction.";
" to incorrect type. Expected shared_ptr<IFunction>.";
throw std::runtime_error(message);
}
}
......@@ -1134,8 +1134,9 @@ IPropertyManager::getValue<boost::shared_ptr<const Mantid::API::IFunction>>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const IFunction.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<IFunction>.";
throw std::runtime_error(message);
}
}
......
......@@ -85,8 +85,9 @@ IPropertyManager::getValue<Mantid::API::IMDEventWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected IMDEventWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<IMDEventWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -106,7 +107,7 @@ IPropertyManager::getValue<Mantid::API::IMDEventWorkspace_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const IMDEventWorkspace.";
" to incorrect type. Expected const shared_ptr<IMDEventWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -51,8 +51,9 @@ IPropertyManager::getValue<Mantid::API::IMDHistoWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected IMDHistoWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<IMDHistoWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -71,7 +72,7 @@ IPropertyManager::getValue<Mantid::API::IMDHistoWorkspace_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const IMDHistoWorkspace.";
" to incorrect type. Expected const shared_ptr<IMDHistoWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -155,8 +155,9 @@ IPropertyManager::getValue<Mantid::API::IMDWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected IMDWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<IMDWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -173,8 +174,9 @@ IPropertyManager::getValue<Mantid::API::IMDWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const IMDWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<IMDWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -37,8 +37,9 @@ IPropertyManager::getValue<Mantid::API::IPeaksWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected PeaksWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<PeaksWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -53,8 +54,9 @@ IPropertyManager::getValue<Mantid::API::IPeaksWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const PeaksWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<PeaksWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -107,8 +107,9 @@ IPropertyManager::getValue<API::ITableWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected ITableWorkspace";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<ITableWorkspace>";
throw std::runtime_error(message);
}
}
......@@ -123,8 +124,9 @@ IPropertyManager::getValue<API::ITableWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const ITableWorkspace";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<ITableWorkspace>";
throw std::runtime_error(message);
}
}
......
......@@ -2049,8 +2049,9 @@ IPropertyManager::getValue<Mantid::API::MatrixWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected MatrixWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<MatrixWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -2065,8 +2066,9 @@ IPropertyManager::getValue<Mantid::API::MatrixWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const MatrixWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<MatrixWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -99,7 +99,7 @@ IPropertyManager::getValue<Mantid::API::Workspace_sptr>(
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected Workspace.";
" to incorrect type. Expected shared_ptr<Workspace>.";
throw std::runtime_error(message);
}
}
......@@ -114,8 +114,9 @@ IPropertyManager::getValue<Mantid::API::Workspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const Workspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<Workspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -401,8 +401,9 @@ IPropertyManager::getValue<Mantid::API::WorkspaceGroup_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected WorkspaceGroup.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<WorkspaceGroup>.";
throw std::runtime_error(message);
}
}
......@@ -417,8 +418,9 @@ IPropertyManager::getValue<Mantid::API::WorkspaceGroup_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const WorkspaceGroup.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<WorkspaceGroup>.";
throw std::runtime_error(message);
}
}
......
......@@ -986,8 +986,9 @@ IPropertyManager::getValue<Mantid::DataObjects::EventWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected EventWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<EventWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -1003,8 +1004,9 @@ IPropertyManager::getValue<Mantid::DataObjects::EventWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const EventWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<EventWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -117,8 +117,9 @@ IPropertyManager::getValue<Mantid::DataObjects::GroupingWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected GroupingWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<GroupingWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -136,7 +137,7 @@ IPropertyManager::getValue<Mantid::DataObjects::GroupingWorkspace_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const GroupingWorkspace.";
" to incorrect type. Expected const shared_ptr<GroupingWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -311,8 +311,9 @@ IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected MaskWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<MaskWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -328,8 +329,9 @@ IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const MaskWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<MaskWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -48,8 +48,9 @@ IPropertyManager::getValue<Mantid::DataObjects::OffsetsWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected OffsetsWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<OffsetsWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -67,7 +68,7 @@ IPropertyManager::getValue<Mantid::DataObjects::OffsetsWorkspace_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const OffsetsWorkspace.";
" to incorrect type. Expected const shared_ptr<OffsetsWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -856,8 +856,9 @@ IPropertyManager::getValue<Mantid::DataObjects::PeaksWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected PeaksWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<PeaksWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -873,8 +874,9 @@ IPropertyManager::getValue<Mantid::DataObjects::PeaksWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const PeaksWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<PeaksWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -451,8 +451,9 @@ IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected SpecialWorkspace2D.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<SpecialWorkspace2D>.";
throw std::runtime_error(message);
}
}
......@@ -470,7 +471,7 @@ IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const SpecialWorkspace2D.";
" to incorrect type. Expected const shared_ptr<SpecialWorkspace2D>.";
throw std::runtime_error(message);
}
}
......
......@@ -91,8 +91,9 @@ IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected SplittersWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<SplittersWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -110,7 +111,7 @@ IPropertyManager::getValue<Mantid::DataObjects::SplittersWorkspace_const_sptr>(
} else {
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const SplittersWorkspace.";
" to incorrect type. Expected const shared_ptr<SplittersWorkspace>.";
throw std::runtime_error(message);
}
}
......
......@@ -303,8 +303,9 @@ IPropertyManager::getValue<DataObjects::TableWorkspace_sptr>(
if (prop) {
return *prop;
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected TableWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<TableWorkspace>.";
throw std::runtime_error(message);
}
}
......@@ -319,8 +320,9 @@ IPropertyManager::getValue<DataObjects::TableWorkspace_const_sptr>(
if (prop) {
return prop->operator()();
} else {
std::string message = "Attempt to assign property " + name +
" to incorrect type. Expected const TableWorkspace.";
std::string message =
"Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<TableWorkspace>.";
throw std::runtime_error(message);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment