Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
eval-error.hh
1
#pragma once
2
3
#include "
nix/util/error.hh
"
4
#include "
nix/util/pos-idx.hh
"
5
#include "
nix/store/path.hh
"
6
7
namespace
nix {
8
9
struct
Env
;
10
struct
Expr
;
11
struct
Value
;
12
13
class
EvalState
;
14
template
<
class
T>
15
class
EvalErrorBuilder
;
16
22
class
EvalBaseError :
public
CloneableError<EvalBaseError, Error>
23
{
24
template
<
class
T>
25
friend
class
EvalErrorBuilder;
26
27
void
anchor()
override
;
28
29
public
:
30
EvalState
& state;
31
32
EvalBaseError(
EvalState
& state,
ErrorInfo
&& errorInfo)
33
: CloneableError(errorInfo)
34
, state(state)
35
{
36
}
37
38
template
<
typename
...
Args
>
39
explicit
EvalBaseError(
EvalState
& state,
const
std::string & formatString,
const
Args
&... formatArgs)
40
: CloneableError(formatString, formatArgs...)
41
, state(state)
42
{
43
}
44
};
45
52
MakeError(EvalError,
EvalBaseError
);
53
MakeError(AssertionError, EvalError);
54
MakeError(ThrownError, AssertionError);
55
MakeError(Abort, EvalError);
56
MakeError(TypeError, EvalError);
57
MakeError(UndefinedVarError, EvalError);
58
MakeError(MissingArgumentError, EvalError);
59
60
class
ParseError
final :
public
CloneableError<ParseError, Error>
61
{
62
bool
isUnexpectedEOF =
false
;
63
64
void
anchor()
override
;
65
66
public
:
67
using
CloneableError::CloneableError;
68
69
ParseError
&& setIncomplete(
bool
val) &&
70
{
71
isUnexpectedEOF = val;
72
return
std::move(*
this
);
73
}
74
78
bool
isIncomplete
() const noexcept
79
{
80
return
isUnexpectedEOF;
81
}
82
};
83
84
class
InfiniteRecursionError :
public
CloneableError<InfiniteRecursionError, EvalError>
85
{
86
void
anchor()
override
;
87
88
public
:
89
95
const
Value
*
const
v
;
96
97
template
<
typename
...
Args
>
98
explicit
InfiniteRecursionError(
EvalState
& state,
const
Value
*
v
,
const
Args
&... args)
99
: CloneableError(state, args...)
100
,
v
(
v
)
101
{
102
}
103
};
104
110
class
StackOverflowError :
public
CloneableError<StackOverflowError, EvalBaseError>
111
{
112
void
anchor()
override
;
113
114
public
:
115
StackOverflowError(
EvalState
& state)
116
: CloneableError(state,
"stack overflow; max-call-depth exceeded"
)
117
{
118
}
119
};
120
121
MakeError(IFDError,
EvalBaseError
);
122
129
MakeError(RecoverableEvalError,
EvalBaseError
);
130
131
class
InvalidPathError :
public
CloneableError<InvalidPathError, EvalError>
132
{
133
void
anchor()
override
;
134
135
public
:
136
StorePath
path;
137
138
InvalidPathError(
EvalState
& state,
const
StorePath
& path);
139
};
140
146
template
<
class
T>
147
class
EvalErrorBuilder final
148
{
149
friend
class
EvalState;
150
151
template
<
typename
...
Args
>
152
explicit
EvalErrorBuilder(EvalState & state,
const
Args
&... args)
153
: error(T(state, args...))
154
{
155
}
156
157
public
:
158
T error;
159
160
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withExitStatus(
unsigned
int
exitStatus);
161
162
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & atPos(
PosIdx
pos);
163
164
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & atPos(
Value
& value,
PosIdx
fallback = noPos);
165
166
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withTrace(
PosIdx
pos,
const
std::string_view text);
167
168
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withFrameTrace(
PosIdx
pos,
const
std::string_view text);
169
170
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withSuggestions(
Suggestions
& s);
171
172
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & withFrame(
const
Env
& e,
const
Expr
& ex);
173
174
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & addTrace(
PosIdx
pos,
HintFmt
hint);
175
176
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> & setIsFromExpr();
177
178
template
<
typename
...
Args
>
179
[[nodiscard, gnu::noinline]] EvalErrorBuilder<T> &
180
addTrace(
PosIdx
pos, std::string_view formatString,
const
Args
&... formatArgs);
181
185
[[gnu::noinline, gnu::noreturn]]
void
debugThrow
();
186
191
[[gnu::noinline, gnu::noreturn]]
void
panic
();
192
};
193
194
}
// namespace nix
nix::Args
Definition
args.hh:29
nix::EvalBaseError
Definition
eval-error.hh:23
nix::EvalErrorBuilder
Definition
eval-error.hh:148
nix::EvalErrorBuilder::debugThrow
void debugThrow()
Definition
eval-error.cc:89
nix::EvalErrorBuilder::panic
void panic()
Definition
eval-error.cc:104
nix::EvalState
Definition
eval.hh:420
nix::HintFmt
Definition
fmt.hh:169
nix::InfiniteRecursionError::v
const Value *const v
Definition
eval-error.hh:95
nix::ParseError
Definition
eval-error.hh:61
nix::ParseError::isIncomplete
bool isIncomplete() const noexcept
Definition
eval-error.hh:78
nix::PosIdx
Definition
pos-idx.hh:10
nix::StorePath
Definition
path.hh:33
nix::Suggestions
Definition
suggestions.hh:28
error.hh
This file defines two main structs/classes used in nix error handling.
path.hh
pos-idx.hh
nix::Env
Definition
eval.hh:197
nix::ErrorInfo
Definition
error.hh:109
nix::Expr
Definition
nixexpr.hh:100
nix::Value
Definition
value.hh:1166
libexpr
include
nix
expr
eval-error.hh
Generated by
1.18.0