Skip to content

Commit 034d666

Browse files
authored
Replace use of TLOG_FATAL() with tprintf() and exit(1) (#349)
Asserts should not be used for missing or invalid input in the command line! This leads to a bad UX.
1 parent 32d5ef6 commit 034d666

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

training/text2image.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,10 @@ int main(int argc, char** argv) {
441441
if (!FLAGS_find_fonts && !FontUtils::IsAvailableFont(FLAGS_font.c_str())) {
442442
string pango_name;
443443
if (!FontUtils::IsAvailableFont(FLAGS_font.c_str(), &pango_name)) {
444-
tprintf("Could not find font named %s. Pango suggested font %s\n",
444+
tprintf("Could not find font named %s. Pango suggested font %s\n"
445+
"Please correct --font arg.\n",
445446
FLAGS_font.c_str(), pango_name.c_str());
446-
TLOG_FATAL("Please correct --font arg.");
447+
exit(1);
447448
}
448449
}
449450

@@ -487,7 +488,8 @@ int main(int argc, char** argv) {
487488
render.set_gravity_hint_strong(true);
488489
render.set_render_fullwidth_latin(true);
489490
} else {
490-
TLOG_FATAL("Invalid writing mode : %s\n", FLAGS_writing_mode.c_str());
491+
tprintf("Invalid writing mode: %s\n", FLAGS_writing_mode.c_str());
492+
exit(1);
491493
}
492494

493495
string src_utf8;
@@ -512,8 +514,9 @@ int main(int argc, char** argv) {
512514
UNICHARSET unicharset;
513515
if (FLAGS_render_ngrams && !FLAGS_unicharset_file.empty() &&
514516
!unicharset.load_from_file(FLAGS_unicharset_file.c_str())) {
515-
TLOG_FATAL("Failed to load unicharset from file %s\n",
517+
tprintf("Failed to load unicharset from file %s\n",
516518
FLAGS_unicharset_file.c_str());
519+
exit(1);
517520
}
518521

519522
// If we are rendering ngrams that will be OCRed later, shuffle them so that

0 commit comments

Comments
 (0)