aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/error.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-02-28 18:04:39 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-02-28 18:29:33 +0000
commitc863e5f338947ecff275a67725ecf50b2a47bdb5 (patch)
tree733893d760809edcbc55c7aa8078ab84fcd2aa73 /src/libutil/error.hh
parent7869be49c2735280ceabbd13c087b4a06444ae63 (diff)
parentb592359c565e0220545ba146b32f367e4ecdb23f (diff)
Merge remote-tracking branch 'upstream/master' into trustless-remote-builder-simple
Diffstat (limited to 'src/libutil/error.hh')
-rw-r--r--src/libutil/error.hh28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index ff58d3e00..d55e1d701 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -61,16 +61,16 @@ typedef enum {
// the lines of code surrounding an error.
struct LinesOfCode {
- std::optional<string> prevLineOfCode;
- std::optional<string> errLineOfCode;
- std::optional<string> nextLineOfCode;
+ std::optional<std::string> prevLineOfCode;
+ std::optional<std::string> errLineOfCode;
+ std::optional<std::string> nextLineOfCode;
};
// ErrPos indicates the location of an error in a nix file.
struct ErrPos {
int line = 0;
int column = 0;
- string file;
+ std::string file;
FileOrigin origin;
operator bool() const
@@ -80,7 +80,7 @@ struct ErrPos {
// convert from the Pos struct, found in libexpr.
template <class P>
- ErrPos& operator=(const P &pos)
+ ErrPos & operator=(const P & pos)
{
origin = pos.origin;
line = pos.line;
@@ -94,7 +94,7 @@ struct ErrPos {
}
template <class P>
- ErrPos(const P &p)
+ ErrPos(const P & p)
{
*this = p;
}
@@ -107,15 +107,15 @@ struct Trace {
struct ErrorInfo {
Verbosity level;
- string name; // FIXME: rename
+ std::string name; // FIXME: rename
hintformat msg;
std::optional<ErrPos> errPos;
std::list<Trace> traces;
- static std::optional<string> programName;
+ static std::optional<std::string> programName;
};
-std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool showTrace);
+std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool showTrace);
/* BaseError should generally not be caught, as it has Interrupted as
a subclass. Catch Error instead. */
@@ -124,8 +124,8 @@ class BaseError : public std::exception
protected:
mutable ErrorInfo err;
- mutable std::optional<string> what_;
- const string& calcWhat() const;
+ mutable std::optional<std::string> what_;
+ const std::string & calcWhat() const;
public:
unsigned int status = 1; // exit status
@@ -137,7 +137,7 @@ public:
{ }
template<typename... Args>
- BaseError(const std::string & fs, const Args & ... args)
+ explicit BaseError(const std::string & fs, const Args & ... args)
: err { .level = lvlError, .msg = hintfmt(fs, args...) }
{ }
@@ -162,11 +162,11 @@ public:
const char * what() const noexcept override { return calcWhat().c_str(); }
#endif
- const string & msg() const { return calcWhat(); }
+ const std::string & msg() const { return calcWhat(); }
const ErrorInfo & info() const { calcWhat(); return err; }
template<typename... Args>
- BaseError & addTrace(std::optional<ErrPos> e, const string &fs, const Args & ... args)
+ BaseError & addTrace(std::optional<ErrPos> e, const std::string & fs, const Args & ... args)
{
return addTrace(e, hintfmt(fs, args...));
}