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