diff options
author | Harald Musum <musum@yahooinc.com> | 2022-02-07 14:18:04 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-02-07 14:18:04 +0100 |
commit | 9cd47d82ce12f2f76ee0c036a06d10e09ecd2aca (patch) | |
tree | c3770bb149748ebf31c9aa8625011ae2f2f66c23 /config | |
parent | 3d13b2df6632929fba8fa63fd3a712190898d5cd (diff) |
Fail if schema file cannot be opened
Diffstat (limited to 'config')
-rw-r--r-- | config/src/apps/vespa-get-config/getconfig.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index 347d92e0ef4..af8c7120d19 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -196,15 +196,20 @@ GetConfig::Main() schema = schemaString; } if (debugging) { - printf("Using schema in %s\n", schema.c_str()); + printf("Using schema from '%s'\n", schema.c_str()); } std::ifstream is; is.open(schema); std::string item; - while (std::getline(is, item)) { - if (item.find("namespace=") == std::string::npos) { - defSchema.push_back(item); + if (is.is_open()) { + while (std::getline(is, item)) { + if (item.find("namespace=") == std::string::npos) { + defSchema.push_back(item); + } } + } else { + fprintf(stderr, "Could not open schema file '%s'\n", schema.c_str()); + return 1; } is.close(); |