|
clang 23.0.0git
|
Fluent API for constructing contextual errors. More...
#include "clang/Analysis/Scalable/Support/ErrorBuilder.h"
Public Member Functions | |
| ErrorBuilder & | context (const char *Msg) |
| Add context information as a plain string. | |
| template<typename... Args> | |
| ErrorBuilder & | context (const char *Fmt, Args &&...ArgVals) |
| Add context information with formatted string. | |
| llvm::Error | build () const |
| Build and return the final error. | |
Static Public Member Functions | |
| template<typename... Args> | |
| static ErrorBuilder | create (std::error_code EC, const char *Fmt, Args &&...ArgVals) |
| Create an ErrorBuilder with an error code and formatted message. | |
| template<typename... Args> | |
| static ErrorBuilder | create (std::errc EC, const char *Fmt, Args &&...ArgVals) |
| Convenience overload that accepts std::errc instead of std::error_code. | |
| static ErrorBuilder | wrap (llvm::Error E) |
| Wrap an existing error and optionally add context. | |
| template<typename... Args> | |
| static void | fatal (const char *Fmt, Args &&...ArgVals) |
| Report a fatal error with formatted message and terminate execution. | |
Fluent API for constructing contextual errors.
ErrorBuilder allows building error messages with layered context information. Context is added innermost to outermost, and the final error message presents the context in reverse order (outermost first).
Example usage:
Definition at line 40 of file ErrorBuilder.h.
| llvm::Error clang::ssaf::ErrorBuilder::build | ( | ) | const |
Build and return the final error.
Constructs an llvm::Error with all accumulated context. The context is presented in reverse order: most recent context first, original error message last. Each context layer is separated by a newline.
create() or wrap(). Constructing an ErrorBuilder directly is not supported.Example output:
Definition at line 54 of file ErrorBuilder.cpp.
References clang::ssaf::ContextSeparator.
Referenced by clang::ssaf::EntityLinker::link(), clang::ssaf::JSONFormat::readTUSummary(), and clang::ssaf::JSONFormat::writeTUSummary().
|
inline |
Add context information with formatted string.
Uses llvm::formatv for formatting. Empty messages (after formatting) are ignored and not added to the context stack.
| Fmt | Format string (using llvm::formatv syntax). |
| ArgVals | Arguments for the format string. |
Example:
Definition at line 150 of file ErrorBuilder.h.
| ErrorBuilder & clang::ssaf::ErrorBuilder::context | ( | const char * | Msg | ) |
Add context information as a plain string.
Empty strings are ignored and not added to the context stack.
| Msg | Context message to add. Must be a null-terminated string. |
Example:
Definition at line 49 of file ErrorBuilder.cpp.
Referenced by clang::ssaf::JSONFormat::readTUSummary(), and clang::ssaf::JSONFormat::writeTUSummary().
|
inlinestatic |
Convenience overload that accepts std::errc instead of std::error_code.
| EC | The error condition for this error. |
| Fmt | Format string for the error message. |
| ArgVals | Arguments for the format string. |
Definition at line 91 of file ErrorBuilder.h.
References create().
|
inlinestatic |
Create an ErrorBuilder with an error code and formatted message.
| EC | The error code for this error. |
| Fmt | Format string for the error message (using llvm::formatv). |
| ArgVals | Arguments for the format string. |
Example:
Definition at line 77 of file ErrorBuilder.h.
Referenced by create(), clang::ssaf::EntityLinker::link(), and clang::ssaf::JSONFormat::readTUSummary().
|
inlinestatic |
Report a fatal error with formatted message and terminate execution.
Combines llvm::formatv and llvm::report_fatal_error. This is a static utility method for reporting unrecoverable errors that indicate bugs or corrupted data.
| Fmt | Format string for the error message (using llvm::formatv). |
| ArgVals | Arguments for the format string. |
Fmt must be a valid llvm::formatv format string with the correct number and types of arguments. An invalid format string is undefined behaviour.Example:
Definition at line 199 of file ErrorBuilder.h.
References noreturn.
|
static |
Wrap an existing error and optionally add context.
Extracts the error code and message(s) from the given error. If multiple errors are joined (via llvm::joinErrors), their messages are combined using " + " separator.
| E | The error to wrap. Must be a failure (cannot be success). |
Example:
Definition at line 19 of file ErrorBuilder.cpp.
References clang::ssaf::ErrorSeparator.
Referenced by clang::ssaf::JSONFormat::readTUSummary(), and clang::ssaf::JSONFormat::writeTUSummary().