From 237190c02623d88ccf0f791d50c395bbfd28e76b Mon Sep 17 00:00:00 2001 From: Keith Brown Date: Mon, 21 Oct 2013 14:02:03 +0100 Subject: [PATCH] Clarified some errors and comments Errors now include the line number in the file if it's avialable to them. Some comments have been deleted or improved Refs #7732 --- .../Framework/DataHandling/src/LoadAscii.cpp | 2 +- .../Framework/DataHandling/src/LoadAscii2.cpp | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/src/LoadAscii.cpp b/Code/Mantid/Framework/DataHandling/src/LoadAscii.cpp index 3378f1fac3e0..aad02577bf20 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadAscii.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadAscii.cpp @@ -88,7 +88,7 @@ namespace Mantid */ bool LoadAscii::isAscii(FILE *file) { - char data[256]; + char data[256]; char *pend = &data[fread(data, 1, sizeof(data), file)]; fseek(file,0,SEEK_SET); /* diff --git a/Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp b/Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp index cde94d8402bb..4031e69f7772 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp @@ -152,7 +152,6 @@ namespace Mantid if (line.empty()) { //the line is empty, treat as a break before a new spectra - //Signifies the start of a new spectra if it wasn't preceeded with another blank line or a spectra ID newSpectra(); } else if (!skipLine(line)) @@ -185,7 +184,7 @@ namespace Mantid if (cols > 4 || cols < 0) { //there were more separators than there should have been, which isn't right, or something went rather wrong - throw std::runtime_error("Sets of values must have between 1 and 3 delimiters"); + throw std::runtime_error("Line " + std::to_string(lineNo) + ": Sets of values must have between 1 and 3 delimiters"); } else if (cols == 1) { @@ -200,10 +199,9 @@ namespace Mantid else { //if not then they've ommitted IDs in the the file previously and just decided to include one (which is wrong and confuses everything) - throw std::runtime_error("Inconsistent inclusion of spectra IDs. All spectra must have IDs or all spectra must not have IDs. " - "Check for blank lines, as they symbolize the end of one spectra and the start of another."); + throw std::runtime_error("Line " + std::to_string(lineNo) + ": Inconsistent inclusion of spectra IDs. All spectra must have IDs or all spectra must not have IDs. " + "Check for blank lines, as they symbolize the end of one spectra and the start of another. Also check for spectra IDs with no associated bins."); } - //this will overwrite the old id in the case of consecutive spectra ID lines m_curSpectra->setSpectrumNo(boost::lexical_cast(*(columns.begin()))); } else if (cols != 1) @@ -217,12 +215,12 @@ namespace Mantid } else if (badLine(line)) { - throw std::runtime_error("Unexpected character found at beggining of line " + std::to_string(lineNo) + ". Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +"."); + throw std::runtime_error("Line " + std::to_string(lineNo) + ": Unexpected character found at beggining of line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +"."); } else { //strictly speaking this should never be hit, but just being sure - throw std::runtime_error("Unknown format at line " + std::to_string(lineNo) + ". Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +"."); + throw std::runtime_error("Line " + std::to_string(lineNo) + ": Unknown format at line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +"."); } } @@ -310,7 +308,7 @@ namespace Mantid } /** - * Check if the file has been found to incosistantly include spectra IDs + * Check if the file has been found to inconsistantly include spectra IDs * @param[in] columns : the columns of values in the current line of data */ void LoadAscii2::addToCurrentSpectra(std::list & columns)