14#ifndef CPPINTEROP_LIB_ERRORINTERNAL_H
15#define CPPINTEROP_LIB_ERRORINTERNAL_H
20#include "llvm/Support/Error.h"
21#include "llvm/Support/raw_ostream.h"
27#include <system_error>
32struct InterpreterInfo;
41 DiagnosticSeverity
Sev = DiagnosticSeverity::Error;
75 StatusError(Status C, std::string M) : Code(C), Message(std::move(M)) {}
77 void log(llvm::raw_ostream& OS)
const override;
78 [[nodiscard]] std::error_code convertToErrorCode()
const override;
92 std::string Message,
const char* Producer,
93 const char* ProducerSig);
100 const char* ProducerSig);
106 const char* Producer,
const char* ProducerSig) {
108 return Result<T>(std::move(*E));
109 return Result<T>(
drainError(II, E.takeError(), Producer, ProducerSig));
113 const char* Producer,
const char* ProducerSig) {
115 return Result<void>();
116 return Result<void>(
drainError(II, std::move(E), Producer, ProducerSig));
133 InterpRef I =
nullptr);
StatusError(Status C, std::string M)
unsigned GetPendingDiagnosticCount(InterpRef I)
ErrorRef makeError(Status S)
Build an inline-status ErrorRef (no diagnostics, no payload).
ErrorRef drainError(InterpreterInfo *II, llvm::Error E, const char *Producer, const char *ProducerSig)
Drain E into a fresh slice, returning the slice via ErrorRef.
void ClearPendingDiagnostics(InterpRef I)
void DrainPendingInto(InterpreterInfo *II, ErrorSlice *S)
Drain the consumer's per-interp buffer into a slice on failure.
ErrorSlice * AllocSlice(InterpreterInfo *Owner)
Allocate a fresh slice on the heap, refcount 0.
DiagnosticRef GetPendingDiagnostic(unsigned Idx, InterpRef I)
Result< T > makeResult(InterpreterInfo *II, llvm::Expected< T > E, const char *Producer, const char *ProducerSig)
Convert llvm::Expected<T> into Result<T>.
void ClearPending(InterpreterInfo *II)
Body of a slice-encoded error: drained diagnostics, producer attribution, refcount.
std::atomic< uint32_t > Refcount
const char * ProducerSignature
std::deque< StoredDiagView > Diagnostics
Owning record for one captured diagnostic.