14539b441SAlexey Lapshin //===- Error.h --------------------------------------------------*- C++ -*-===// 24539b441SAlexey Lapshin // 34539b441SAlexey Lapshin // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44539b441SAlexey Lapshin // See https://llvm.org/LICENSE.txt for license information. 54539b441SAlexey Lapshin // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64539b441SAlexey Lapshin // 74539b441SAlexey Lapshin //===----------------------------------------------------------------------===// 84539b441SAlexey Lapshin 94539b441SAlexey Lapshin #ifndef LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 104539b441SAlexey Lapshin #define LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 114539b441SAlexey Lapshin 124539b441SAlexey Lapshin #include "llvm/ADT/STLExtras.h" 134539b441SAlexey Lapshin #include "llvm/ADT/StringRef.h" 144539b441SAlexey Lapshin #include "llvm/Support/Debug.h" 154539b441SAlexey Lapshin #include "llvm/Support/Error.h" 164539b441SAlexey Lapshin #include "llvm/Support/Format.h" 174539b441SAlexey Lapshin #include "llvm/Support/WithColor.h" 184539b441SAlexey Lapshin #include "llvm/Support/raw_ostream.h" 19*62c7f035SArchibald Elliott #include "llvm/TargetParser/Triple.h" 204539b441SAlexey Lapshin 214539b441SAlexey Lapshin namespace llvm { 224539b441SAlexey Lapshin namespace dwarfutil { 234539b441SAlexey Lapshin 244539b441SAlexey Lapshin inline void error(Error Err, StringRef Prefix = "") { 254539b441SAlexey Lapshin handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { 264539b441SAlexey Lapshin WithColor::error(errs(), Prefix) << Info.message() << '\n'; 274539b441SAlexey Lapshin }); 284539b441SAlexey Lapshin std::exit(EXIT_FAILURE); 294539b441SAlexey Lapshin } 304539b441SAlexey Lapshin 314539b441SAlexey Lapshin inline void warning(const Twine &Message, StringRef Prefix = "") { 324539b441SAlexey Lapshin WithColor::warning(errs(), Prefix) << Message << '\n'; 334539b441SAlexey Lapshin } 344539b441SAlexey Lapshin verbose(const Twine & Message,bool Verbose)354539b441SAlexey Lapshininline void verbose(const Twine &Message, bool Verbose) { 364539b441SAlexey Lapshin if (Verbose) 374539b441SAlexey Lapshin outs() << Message << '\n'; 384539b441SAlexey Lapshin } 394539b441SAlexey Lapshin 404539b441SAlexey Lapshin } // end of namespace dwarfutil 414539b441SAlexey Lapshin } // end of namespace llvm 424539b441SAlexey Lapshin 434539b441SAlexey Lapshin #endif // LLVM_TOOLS_LLVM_DWARFUTIL_ERROR_H 44