Improved error messages

This commit is contained in:
Olivier Teulière 2009-06-21 12:32:25 +00:00
parent b8c04ddab2
commit 9b8526b451
2 changed files with 17 additions and 3 deletions

View file

@ -324,7 +324,19 @@ unsigned int makenode(const wchar_t *iPrefix, ostream &outfile,
newEdge.ptr = 0;
newEdge.term = 0;
newEdge.last = 0;
newEdge.chr = iHeader.getCodeFromChar(*global_endstring++ = *global_input++);
try
{
newEdge.chr = iHeader.getCodeFromChar(*global_endstring++ = *global_input++);
}
catch (DicException &e)
{
// If an invalid character is found, be specific about the problem
ostringstream oss;
oss << "Error on line " << 1 + ioHeaderInfo.nwords
<< ", col " << global_endstring - global_stringbuf
<< ": " << e.what() << endl;
throw DicException(oss.str());
}
edges.push_back(newEdge);
// End of a word?

View file

@ -250,8 +250,10 @@ unsigned int Header::getCodeFromChar(wchar_t iChar) const
m_mapCodeFromChar.find(iChar);
if (pair == m_mapCodeFromChar.end())
{
throw DicException("Header::getCodeFromChar: No code for letter " +
convertToMb(iChar));
char s[5];
sprintf(s, "%d", iChar);
throw DicException("Header::getCodeFromChar: No code for letter '" +
convertToMb(iChar) + "' (val=" + string(s) + ")");
}
return pair->second;
}