class StringError

Declaration

class StringError : public ErrorInfo { /* full declaration omitted */ };

Description

This class wraps a string in an Error. StringError is useful in cases where the client is not expected to be able to consume the specific error message programmatically (for example, if the error message is to be presented to the user). StringError can also be used when additional information is to be printed along with a error_code message. Depending on the constructor called, this class can either display: 1. the error_code message (ECError behavior) 2. a string 3. the error_code message and a string These behaviors are useful when subtyping is required; for example, when a specific library needs an explicit error type. In the example below, PDBError is derived from StringError:

Declared at: llvm/include/llvm/Support/Error.h:1216

Inherits from: ErrorInfo

Member Variables

private std::string Msg
private std::error_code EC
private const bool PrintMsgOnly = false
public static char ID

Method Overview

  • public StringError(std::error_code EC, const llvm::Twine & S = llvm::Twine())
  • public StringError(const llvm::Twine & S, std::error_code EC)
  • public std::error_code convertToErrorCode() const
  • public const std::string & getMessage() const
  • public void log(llvm::raw_ostream & OS) const

Methods

StringError(std::error_code EC,
            const llvm::Twine& S = llvm::Twine())

Declared at: llvm/include/llvm/Support/Error.h:1221

Parameters

std::error_code EC
const llvm::Twine& S = llvm::Twine()

StringError(const llvm::Twine& S,
            std::error_code EC)

Declared at: llvm/include/llvm/Support/Error.h:1224

Parameters

const llvm::Twine& S
std::error_code EC

std::error_code convertToErrorCode() const

Description

Convert this error to a std::error_code. This is a temporary crutch to enable interaction with code still using std::error_code. It will be removed in the future.

Declared at: llvm/include/llvm/Support/Error.h:1227

const std::string& getMessage() const

Declared at: llvm/include/llvm/Support/Error.h:1229

void log(llvm::raw_ostream& OS) const

Description

Print an error message to an output stream.

Declared at: llvm/include/llvm/Support/Error.h:1226

Parameters

llvm::raw_ostream& OS