Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/base/io-funcs-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ template<class T> void WriteBasicType(std::ostream &os,
os << t << " ";
}
if (os.fail()) {
throw std::runtime_error("Write failure in WriteBasicType.");
KALDI_ERR << "Write failure in WriteBasicType.";
}
}

Expand Down Expand Up @@ -122,7 +122,7 @@ inline void WriteIntegerPairVector(std::ostream &os, bool binary,
os << "]\n";
}
if (os.fail()) {
throw std::runtime_error("Write failure in WriteIntegerPairVector.");
KALDI_ERR << "Write failure in WriteIntegerPairVector.";
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ template<class T> inline void WriteIntegerVector(std::ostream &os, bool binary,
os << "]\n";
}
if (os.fail()) {
throw std::runtime_error("Write failure in WriteIntegerVector.");
KALDI_ERR << "Write failure in WriteIntegerVector.";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/io-funcs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void WriteToken(std::ostream &os, bool binary, const char *token) {
CheckToken(token); // make sure it's valid (can be read back)
os << token << " ";
if (os.fail()) {
throw std::runtime_error("Write failure in WriteToken.");
KALDI_ERR << "Write failure in WriteToken.";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/base/io-funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace kaldi {
We also want to have control over whitespace in text mode without affecting
the meaning of the file, for pretty-printing purposes.

Errors are handled by throwing an exception (std::runtime_error).
Errors are handled by throwing a KaldiFatalError exception.

For integer and floating-point types (and boolean values):

Expand Down
7 changes: 3 additions & 4 deletions src/base/kaldi-error-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ void UnitTestError() {
} // end namespace kaldi.

int main() {
kaldi::g_program_name = "/foo/bar/kaldi-error-test";
kaldi::SetProgramName("/foo/bar/kaldi-error-test");
try {
kaldi::UnitTestError();
KALDI_ASSERT(0); // should not happen.
exit(1);
} catch(std::runtime_error &r) {
std::cout << "UnitTestError: the error we generated was: " << r.what();
} catch(kaldi::KaldiFatalError &e) {
std::cout << "The error we generated was: '" << e.KaldiMessage() << "'\n";
}
}

Loading