diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 51ce532fdd..ca88e0556d 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -295,6 +295,10 @@ int main(int argc, char** argv) { ("stderr-progress", "output progress to stderr stream") ("yes,y", "answer 'yes' automatically to possible confirmation queries (e.g. overwriting an existing output file)") ("no-progress", "suppress possible progress bar type of prints that use carriage return") + ("fail-on-error", "return a non-zero exit code when one or more errors were logged during " + "geometry conversion (e.g. an element failed to convert). By default IfcConvert exits " + "successfully as long as an output file could be written, even if some elements were " + "silently dropped. Enable this flag so scripts and CI can detect partial conversions.") ("log-format", po::value(&log_format), "log format: plain or json") ("log-file", new po::typed_value(&log_file), "redirect log output to file"); @@ -438,6 +442,7 @@ int main(int argc, char** argv) { const bool mmap = vmap.count("mmap") != 0; const bool no_progress = vmap.count("no-progress") != 0; + const bool fail_on_error = vmap.count("fail-on-error") != 0; const bool quiet = vmap.count("quiet") != 0; const bool stderr_progress = vmap.count("stderr-progress") != 0; @@ -1027,6 +1032,11 @@ int main(int argc, char** argv) { successful = false; } + if (fail_on_error && logger.max_severity() >= ::logger::LOG_ERROR) { + logger.error("SYS", 26, "Errors encountered during processing, failing due to --fail-on-error."); + successful = false; + } + if (logger.verbosity() == ::logger::LOG_PERF) { logger.print_performance_stats(); }