1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 15:51:15 +02:00

Revert "Revert "Merge pull request #6204 from layus/coerce-string""

This reverts commit 9b33ef3879.
This commit is contained in:
Guillaume Maudoux 2023-01-19 13:23:04 +01:00
parent 38b90c618f
commit e4726a0c79
31 changed files with 986 additions and 863 deletions

View file

@ -86,6 +86,7 @@ void printCodeLines(std::ostream & out,
struct Trace {
std::shared_ptr<AbstractPos> pos;
hintformat hint;
bool frame;
};
struct ErrorInfo {
@ -114,6 +115,8 @@ protected:
public:
unsigned int status = 1; // exit status
BaseError(const BaseError &) = default;
template<typename... Args>
BaseError(unsigned int status, const Args & ... args)
: err { .level = lvlError, .msg = hintfmt(args...) }
@ -152,15 +155,22 @@ public:
const std::string & msg() const { return calcWhat(); }
const ErrorInfo & info() const { calcWhat(); return err; }
template<typename... Args>
void addTrace(std::shared_ptr<AbstractPos> && e, const std::string & fs, const Args & ... args)
void pushTrace(Trace trace)
{
addTrace(std::move(e), hintfmt(fs, args...));
err.traces.push_front(trace);
}
void addTrace(std::shared_ptr<AbstractPos> && e, hintformat hint);
template<typename... Args>
void addTrace(std::shared_ptr<AbstractPos> && e, std::string_view fs, const Args & ... args)
{
addTrace(std::move(e), hintfmt(std::string(fs), args...));
}
void addTrace(std::shared_ptr<AbstractPos> && e, hintformat hint, bool frame = false);
bool hasTrace() const { return !err.traces.empty(); }
const ErrorInfo & info() { return err; };
};
#define MakeError(newClass, superClass) \