From 5c82a446b9110cf27958ad9c82535b84d0565e10 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 6 Oct 2019 17:25:40 -0500 Subject: Beginnings of some extremely basic parsing and a utility --- util/output.hh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 util/output.hh (limited to 'util/output.hh') 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 +#include + +/*! 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_ */ -- cgit v1.2.3-60-g2f50