Skip to content

Commit ba2c52d

Browse files
committed
unify error messages
1 parent 41b00b4 commit ba2c52d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/build.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int run(int argc, char **argv) {
2525

2626
if (!fs::exists("CMakeLists.txt"))
2727
if (gen::generate_cmake("."))
28-
throw std::runtime_error("CMake generation failure!");
28+
throw std::runtime_error("[cmkr] error: CMake generation failure!");
2929

3030
ss << "cmake -S. -B" << cmake.bin_dir << " ";
3131

src/cmake.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ std::vector<std::string> to_string_vec(
2121

2222
CMake::CMake(const std::string &path, bool build) {
2323
if (!fs::exists(fs::path(path) / "cmake.toml")) {
24-
throw std::runtime_error("No cmake.toml was found!");
24+
throw std::runtime_error("[cmkr] error: No cmake.toml was found!");
2525
}
2626
const auto toml = toml::parse((fs::path(path) / "cmake.toml").string());
2727
if (build) {

src/gen.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ std::string format(const char *fmt, Args... args) {
3333
char *buf = new char[sz];
3434
int ret = snprintf(buf, sz, fmt, args...);
3535
if (ret != sz - 1)
36-
throw std::runtime_error("Error formatting string!");
36+
throw std::runtime_error("[cmkr] error: Error formatting string!");
3737
std::string temp(buf, buf + sz - 1);
3838
delete[] buf;
3939
return temp;
@@ -80,7 +80,7 @@ int generate_project(const char *str) {
8080
dest = "include/" + dir_name;
8181
} else {
8282
throw std::runtime_error(
83-
"Unknown project type. Types are exe, lib, shared, static, interface!");
83+
"[cmkr] error: Unknown project type. Types are exe, lib, shared, static, interface!");
8484
}
8585

8686
const auto tomlbuf = detail::format(cmake_toml, dir_name.c_str(), dir_name.c_str(), str,
@@ -257,7 +257,7 @@ int generate_cmake(const char *path) {
257257
add_command = "add_library";
258258
} else {
259259
throw std::runtime_error(
260-
"Unknown binary type! Supported types are exe, shared and static");
260+
"[cmkr] error: Unknown binary type! Supported types are exe, lib, shared, static, interface");
261261
}
262262

263263
if (!bin.sources.empty()) {
@@ -391,6 +391,8 @@ int generate_cmake(const char *path) {
391391
if (fs::exists(fs::path(sub) / "cmake.toml"))
392392
generate_cmake(sub.c_str());
393393
}
394+
} else {
395+
throw std::runtime_error("[cmkr] error: No cmake.toml found!");
394396
}
395397
return 0;
396398
}

0 commit comments

Comments
 (0)