Skip to content

Commit

Permalink
Improve error msg when a file from a range is not found. Refs #6445
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed May 21, 2013
1 parent 74ec494 commit 414e7fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Code/Mantid/Framework/API/src/FileFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,17 @@ namespace Mantid
runPart = hint.substr(nChars);
}

unsigned int irunPart = boost::lexical_cast<unsigned int>( runPart );
unsigned int irunPart(0);
try
{
irunPart = boost::lexical_cast<unsigned int>( runPart );
}
catch(boost::bad_lexical_cast &)
{
std::ostringstream os;
os << "Cannot convert '" << runPart << "' to run number.";
throw std::invalid_argument(os.str());
}
Kernel::InstrumentInfo instr = Kernel::ConfigService::Instance().getInstrument(instrPart);
size_t nZero = instr.zeroPadding(irunPart);
// remove any leading zeros in case there are too many of them
Expand Down
5 changes: 3 additions & 2 deletions Code/Mantid/Framework/API/src/MultipleFileProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ namespace API
}
catch(const std::runtime_error & re)
{
g_log.debug("MultiFile loading has failed. Acting as standard FileProperty.");
g_log.debug("MultiFile loading has failed. Trying as standard FileProperty.");

const std::string error = setValueAsSingleFile(propValue);

if( error.empty() )
return "";

// If we failed for whatever reason, catch the message and return it.
// If we failed return the error message from the multiple file load attempt as the single file was a guess
// and probably not what the user will expect to see
return re.what();
}
}
Expand Down

0 comments on commit 414e7fe

Please sign in to comment.