mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-03 23:07:14 +03:00
abort -> throw
This commit is contained in:
parent
41e7c6807d
commit
8cc5712808
@ -88,8 +88,7 @@ void FeatureRegistry::Add(const std::string &name, FeatureFactory *factory)
|
||||
std::pair<std::string, boost::shared_ptr<FeatureFactory> > to_ins(name,
|
||||
boost::shared_ptr<FeatureFactory>(factory));
|
||||
if (!registry_.insert(to_ins).second) {
|
||||
cerr << "Duplicate feature name " << name << endl;
|
||||
abort();
|
||||
throw std::runtime_error("Duplicate feature name " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,8 +97,7 @@ FeatureFunction *FeatureRegistry::Construct(size_t startInd,
|
||||
{
|
||||
Map::const_iterator i = registry_.find(name);
|
||||
if (i == registry_.end()) {
|
||||
cerr << "Feature name " << name << " is not registered.";
|
||||
abort();
|
||||
throw std::runtime_error("Feature name " + name + " is not registered");
|
||||
}
|
||||
FeatureFactory *fact = i->second.get();
|
||||
FeatureFunction *ff = fact->Create(startInd, line);
|
||||
|
19
moses2/HypothesisColl.cpp
Normal file → Executable file
19
moses2/HypothesisColl.cpp
Normal file → Executable file
@ -130,25 +130,6 @@ StackAdd HypothesisColl::Add(const HypothesisBase *hypo)
|
||||
const_cast<const HypothesisBase *&>(hypoExisting1);
|
||||
hypoExisting2 = hypo;
|
||||
|
||||
/*
|
||||
Delete(hypoExisting);
|
||||
addRet = m_coll.insert(hypo);
|
||||
UTIL_THROW_IF2(!addRet.second, "couldn't insert hypo "
|
||||
<< hypo << "(" << hypo->hash() << ")");
|
||||
*/
|
||||
/*
|
||||
if (!addRet.second) {
|
||||
cerr << "couldn't insert hypo " << hypo << "(" << hypo->hash() << ")" << endl;
|
||||
cerr << "m_coll=";
|
||||
for (_HCType::const_iterator iter = m_coll.begin(); iter != m_coll.end(); ++iter) {
|
||||
const HypothesisBase *h = *iter;
|
||||
cerr << h << "(" << h->hash() << ") ";
|
||||
}
|
||||
cerr << endl;
|
||||
abort();
|
||||
}
|
||||
*/
|
||||
|
||||
return StackAdd(true, hypoExisting);
|
||||
} else {
|
||||
// already storing the best hypo. discard incoming hypo
|
||||
|
2
moses2/System.cpp
Normal file → Executable file
2
moses2/System.cpp
Normal file → Executable file
@ -214,7 +214,7 @@ void System::IsPb()
|
||||
isPb = false;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
throw std::runtime_error("Unknown search algorithm " + options.search.algo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void DynamicPhraseTable::CreatePTForInput(const ManagerBase &mgr, string phraseT
|
||||
if (system.isPb) {
|
||||
//m_rootPb = new PBNODE();
|
||||
} else {
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
//cerr << "m_rootSCFG=" << m_rootSCFG << endl;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ void DynamicPhraseTable::CreatePTForInput(const ManagerBase &mgr, string phraseT
|
||||
|
||||
//cerr << "target=" << target->Debug(system) << endl;
|
||||
} else {
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void DynamicPhraseTable::CreatePTForInput(const ManagerBase &mgr, string phraseT
|
||||
m_rootPb.SortAndPrune(m_tableLimit, pool, system);
|
||||
//cerr << "root=" << &m_rootPb << endl;
|
||||
} else {
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
}
|
||||
/*
|
||||
BOOST_FOREACH(const PtMem::Node<Word>::Children::value_type &valPair, m_rootPb.GetChildren()) {
|
||||
@ -152,7 +152,7 @@ void DynamicPhraseTable::InitActiveChart(
|
||||
const SCFG::Manager &mgr,
|
||||
SCFG::InputPath &path) const
|
||||
{
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
}
|
||||
|
||||
void DynamicPhraseTable::Lookup(MemPool &pool,
|
||||
@ -161,7 +161,7 @@ void DynamicPhraseTable::Lookup(MemPool &pool,
|
||||
const SCFG::Stacks &stacks,
|
||||
SCFG::InputPath &path) const
|
||||
{
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
}
|
||||
|
||||
void DynamicPhraseTable::LookupGivenNode(
|
||||
@ -173,7 +173,7 @@ void DynamicPhraseTable::LookupGivenNode(
|
||||
const Moses2::Range &subPhraseRange,
|
||||
SCFG::InputPath &outPath) const
|
||||
{
|
||||
abort();
|
||||
throw std::runtime_error("Must be a phrase-based model");
|
||||
}
|
||||
|
||||
}
|
||||
|
6
util/file.cc
Normal file → Executable file
6
util/file.cc
Normal file → Executable file
@ -36,15 +36,13 @@ namespace util {
|
||||
|
||||
scoped_fd::~scoped_fd() {
|
||||
if (fd_ != -1 && close(fd_)) {
|
||||
std::cerr << "Could not close file " << fd_ << std::endl;
|
||||
std::abort();
|
||||
throw std::runtime_error("Could not close file " + fd_);
|
||||
}
|
||||
}
|
||||
|
||||
void scoped_FILE_closer::Close(std::FILE *file) {
|
||||
if (file && std::fclose(file)) {
|
||||
std::cerr << "Could not close file " << file << std::endl;
|
||||
std::abort();
|
||||
throw std::runtime_error("Could not close file ");
|
||||
}
|
||||
}
|
||||
|
||||
|
3
util/mmap.cc
Normal file → Executable file
3
util/mmap.cc
Normal file → Executable file
@ -44,8 +44,7 @@ scoped_mmap::~scoped_mmap() {
|
||||
SyncOrThrow(data_, size_);
|
||||
UnmapOrThrow(data_, size_);
|
||||
} catch (const util::ErrnoException &e) {
|
||||
std::cerr << e.what();
|
||||
abort();
|
||||
throw std::runtime_error(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
util/read_compressed.cc
Normal file → Executable file
6
util/read_compressed.cc
Normal file → Executable file
@ -169,8 +169,7 @@ class GZip {
|
||||
|
||||
~GZip() {
|
||||
if (Z_OK != inflateEnd(&stream_)) {
|
||||
std::cerr << "zlib could not close properly." << std::endl;
|
||||
abort();
|
||||
throw std::runtime_error("zlib could not close properly.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,8 +218,7 @@ class BZip {
|
||||
try {
|
||||
HandleError(BZ2_bzDecompressEnd(&stream_));
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
abort();
|
||||
throw std::runtime_error(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user