Skip to content

Commit

Permalink
updates & further error message for peak workspace Refs #12653
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz Ahmed committed Aug 4, 2015
1 parent 37d3622 commit 2985b1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
23 changes: 20 additions & 3 deletions Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,19 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) {
// Get information from all but data group
std::string parameterStr;
// Hop to the right point /mantid_workspace_1
m_cppFile->openPath(entry.path()); // This is
try {
m_cppFile->openPath(entry.path()); // This is
} catch (std::runtime_error &re) {
throw std::runtime_error("Error while opening a path in a Peaks entry in a "
"Nexus processed file. "
"This path is wrong: " +
entry.path() +
". Lower level error description: " + re.what());
}
try {
// This loads logs, sample, and instrument.
peakWS->loadExperimentInfoNexus(getPropertyValue("Filename"), m_cppFile, parameterStr);
peakWS->loadExperimentInfoNexus(getPropertyValue("Filename"), m_cppFile,
parameterStr);
} catch (std::exception &e) {
g_log.information("Error loading Instrument section of nxs file");
g_log.information(e.what());
Expand All @@ -1036,7 +1045,15 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) {
// Coordinates - Older versions did not have the separate field but used a log
// value
uint32_t loadCoord(0);
m_cppFile->openGroup("peaks_workspace", "NXentry");
const std::string peaksWSName = "peaks_workspace";
try {
m_cppFile->openGroup(peaksWSName, "NXentry");
} catch (std::runtime_error &re) {
throw std::runtime_error(
"Error while opening a peaks workspace in a Nexus processed file. "
"Cannot open gropu " +
peaksWSName + ". Lower level error description: " + re.what());
}
try {
m_cppFile->readData("coordinate_system", loadCoord);
peakWS->setCoordinateSystem(
Expand Down
8 changes: 5 additions & 3 deletions Code/Mantid/Framework/Nexus/src/NexusClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ bool NXClass::isValid(const std::string &path) const {
void NXClass::open() {
// if (NX_ERROR == NXopengroup(m_fileID,name().c_str(),NX_class().c_str()))
//{
if (NX_ERROR == NXopengrouppath(m_fileID, name().c_str())) {
if (NX_ERROR == NXopengrouppath(m_fileID, m_path.c_str())) {

throw std::runtime_error("Cannot open group " + name() + " of class " +
NX_class());
NX_class() + " (trying to open path " + m_path +
")");
}
//}
m_open = true;
Expand Down Expand Up @@ -217,7 +218,8 @@ bool NXClass::openLocal(const std::string &nxclass) {
void NXClass::close() {
if (NX_ERROR == NXclosegroup(m_fileID)) {
throw std::runtime_error("Cannot close group " + name() + " of class " +
NX_class());
NX_class() + " (trying to close path " + m_path +
")");
}
m_open = false;
}
Expand Down

0 comments on commit 2985b1c

Please sign in to comment.