summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 17:25:40 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 17:25:40 -0500
commit5c82a446b9110cf27958ad9c82535b84d0565e10 (patch)
tree3c7f9cce9ad0e25e61a41bae9049a692822ed3ae /util
parent65f70c4d29fb2ffc75aad2435ac6b03059bb6e80 (diff)
downloadhorizon-5c82a446b9110cf27958ad9c82535b84d0565e10.tar.gz
horizon-5c82a446b9110cf27958ad9c82535b84d0565e10.tar.bz2
horizon-5c82a446b9110cf27958ad9c82535b84d0565e10.tar.xz
horizon-5c82a446b9110cf27958ad9c82535b84d0565e10.zip
Beginnings of some extremely basic parsing and a utility
Diffstat (limited to 'util')
-rw-r--r--util/output.hh39
1 files changed, 39 insertions, 0 deletions
diff --git a/util/output.hh b/util/output.hh
new file mode 100644
index 0000000..9281301
--- /dev/null
+++ b/util/output.hh
@@ -0,0 +1,39 @@
+/*
+ * output.hh - Miscellaneous output routines
+ * util, the utility library for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#ifndef __HORIZON_OUTPUT_HH_
+#define __HORIZON_OUTPUT_HH_
+
+#include <string>
+#include <iostream>
+
+/*! Prints an error message to the cerr stream.
+ * @param where The location where the error occurred.
+ * @param message The error that occurred.
+ * @param detail Additional detail for the error, if available.
+ * @param pretty Whether or not to colourise (interactive output).
+ */
+inline void output_error(std::string where, std::string message,
+ std::string detail = "", bool pretty = false) {
+ std::cerr << where << ": ";
+ if(pretty) std::cerr << "\033[31;1m";
+ std::cerr << "error: ";
+ if(pretty) std::cerr << "\033[0;1m";
+ std::cerr << message;
+ if(pretty) std::cerr << "\033[0m";
+ if(!detail.empty()) {
+ std::cerr << ": " << detail;
+ }
+ std::cerr << std::endl;
+}
+
+#endif /* !__HORIZON_OUTPUT_HH_ */