1*d415bd75Srobert //===- Error.h --------------------------------------------------*- C++ -*-===// 2*d415bd75Srobert // 3*d415bd75Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*d415bd75Srobert // See https://llvm.org/LICENSE.txt for license information. 5*d415bd75Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*d415bd75Srobert // 7*d415bd75Srobert //===----------------------------------------------------------------------===// 8*d415bd75Srobert 9*d415bd75Srobert #ifndef LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 10*d415bd75Srobert #define LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 11*d415bd75Srobert 12*d415bd75Srobert #include "llvm/ADT/STLExtras.h" 13*d415bd75Srobert #include "llvm/ADT/StringRef.h" 14*d415bd75Srobert #include "llvm/ADT/StringSet.h" 15*d415bd75Srobert #include "llvm/ADT/Triple.h" 16*d415bd75Srobert #include "llvm/Support/Debug.h" 17*d415bd75Srobert #include "llvm/Support/Error.h" 18*d415bd75Srobert #include "llvm/Support/Format.h" 19*d415bd75Srobert #include "llvm/Support/WithColor.h" 20*d415bd75Srobert #include "llvm/Support/raw_ostream.h" 21*d415bd75Srobert 22*d415bd75Srobert namespace llvm { 23*d415bd75Srobert namespace dwarfutil { 24*d415bd75Srobert 25*d415bd75Srobert inline void error(Error Err, StringRef Prefix = "") { 26*d415bd75Srobert handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { 27*d415bd75Srobert WithColor::error(errs(), Prefix) << Info.message() << '\n'; 28*d415bd75Srobert }); 29*d415bd75Srobert std::exit(EXIT_FAILURE); 30*d415bd75Srobert } 31*d415bd75Srobert 32*d415bd75Srobert inline void warning(const Twine &Message, StringRef Prefix = "") { 33*d415bd75Srobert WithColor::warning(errs(), Prefix) << Message << '\n'; 34*d415bd75Srobert } 35*d415bd75Srobert verbose(const Twine & Message,bool Verbose)36*d415bd75Srobertinline void verbose(const Twine &Message, bool Verbose) { 37*d415bd75Srobert if (Verbose) 38*d415bd75Srobert outs() << Message << '\n'; 39*d415bd75Srobert } 40*d415bd75Srobert 41*d415bd75Srobert } // end of namespace dwarfutil 42*d415bd75Srobert } // end of namespace llvm 43*d415bd75Srobert 44*d415bd75Srobert #endif // LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 45