Skip to content
Snippets Groups Projects
Commit b113ffc0 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Fixes #2839. Make the error message from the Load algorithm much clearer if it...

Fixes #2839. Make the error message from the Load algorithm much clearer if it can't find an appropriate loader.
parent c36f078a
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,9 @@ namespace Mantid
/// Create the concrete instance use for the actual loading.
API::IDataFileChecker_sptr createLoader(const std::string & name, const double startProgress = -1.0,
const double endProgress=-1.0, const bool logging = true) const;
/// Set the loader option for use as a sub algorithm.
void setUpLoader(API::IDataFileChecker_sptr loader, const double startProgress = -1.0,
const double endProgress=-1.0, const bool logging = true) const;
/// Set the output workspace(s)
void setOutputWorkspace(const API::IDataFileChecker_sptr loader);
/// Retrieve a pointer to the output workspace from the sub algorithm
......
......@@ -156,10 +156,12 @@ namespace Mantid
{
// Clear what may have been here previously
setPropertyValue("LoaderName", "");
throw std::runtime_error("Cannot find a loader for \"" + filePath + "\"");
throw std::runtime_error("Cannot find an algorithm that is able to load \"" + filePath + "\".\n"
"Check that the file is a supported type.");
}
setPropertyValue("LoaderName", winningLoader->name());
winningLoader->initialize();
setUpLoader(winningLoader);
return winningLoader;
}
......@@ -240,11 +242,15 @@ namespace Mantid
void Load::exec()
{
const std::string loaderName = getPropertyValue("LoaderName");
IDataFileChecker_sptr loader;
if( loaderName.empty() )
{
throw std::invalid_argument("Cannot find loader, LoaderName property has not been set.");
}
IDataFileChecker_sptr loader = createLoader(loaderName,0,1);
loader = getFileLoader(getPropertyValue("Filename"));
}
else
{
loader = createLoader(loaderName,0,1);
}
g_log.information() << "Using " << loaderName << " version " << loader->version() << ".\n";
///get the list properties for the concrete loader load algorithm
const std::vector<Kernel::Property*> & loader_props = loader->getProperties();
......@@ -289,7 +295,20 @@ namespace Mantid
{
throw std::runtime_error("Cannot create loader for \"" + getPropertyValue("Filename") + "\"");
}
setUpLoader(loader,startProgress,endProgress, logging);
return loader;
}
/**
* Set the loader option for use as a sub algorithm.
* @param loader :: Concrete loader
* @param startProgress :: The start progress fraction
* @param endProgress :: The end progress fraction
* @param logging:: If true, enable logging
*/
void Load::setUpLoader(API::IDataFileChecker_sptr loader, const double startProgress,
const double endProgress, const bool logging) const
{
//Set as a child so that we are in control of output storage
loader->setChild(true);
loader->setLogging(logging);
......@@ -309,9 +328,9 @@ namespace Mantid
setChildStartProgress(startProgress);
setChildEndProgress(endProgress);
}
return loader;
}
/**
* Set the output workspace(s) if the load's return workspace has type API::Workspace
* @param loader :: Shared pointer to load algorithm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment