Nix
2.93.0-dev
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
eval-error.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
lix/libutil/box_ptr.hh
"
5
#include "
lix/libutil/error.hh
"
6
#include "
lix/libutil/types.hh
"
7
#include "
lix/libexpr/pos-idx.hh
"
8
#include "
lix/libexpr/pos-table.hh
"
9
10
namespace
nix {
11
12
struct
DebugState;
13
struct
DebugTrace;
14
struct
Env;
15
struct
Expr;
16
struct
Value;
17
18
class
EvalState;
19
template
<
class
T>
20
class
EvalErrorBuilder;
21
22
class
EvalError
:
public
Error
23
{
24
template
<
class
T>
25
friend
class
EvalErrorBuilder
;
26
27
std::shared_ptr<const DebugTrace> frame;
28
29
public
:
30
using
Error::Error;
31
};
32
33
MakeError(ParseError, Error);
34
MakeError(AssertionError,
EvalError
);
35
MakeError(ThrownError, AssertionError);
36
MakeError(Abort,
EvalError
);
37
MakeError(TypeError,
EvalError
);
38
MakeError(UndefinedVarError,
EvalError
);
39
MakeError(MissingArgumentError,
EvalError
);
40
MakeError(RestrictedPathError, Error);
41
MakeError(InfiniteRecursionError,
EvalError
);
42
47
struct
InvalidPathError
:
public
EvalError
48
{
49
public
:
50
Path
path;
51
InvalidPathError
(
const
Path
& path)
52
:
EvalError
(
"path '%s' did not exist in the store during evaluation"
, path)
53
{
54
}
55
};
56
57
template
<
class
T>
58
class
[[nodiscard]]
EvalErrorBuilder
final
59
{
60
const
PosTable
& positions;
61
DebugState
* debug;
62
box_ptr<T>
error;
63
64
public
:
65
template
<
typename
...
Args
>
66
explicit
EvalErrorBuilder
(
const
PosTable
& positions,
DebugState
* debug,
const
Args
&... args)
67
: positions(positions)
68
, debug{debug}
69
, error(make_box_ptr<T>(args...))
70
{
71
}
72
73
[[gnu::noinline]]
EvalErrorBuilder<T>
withExitStatus(
unsigned
int
exitStatus) &&;
74
75
[[gnu::noinline]]
EvalErrorBuilder<T>
atPos(
PosIdx
pos) &&;
76
77
[[gnu::noinline]]
EvalErrorBuilder<T>
atPos(
Value
& value,
PosIdx
fallback = noPos) &&;
78
79
[[gnu::noinline]]
EvalErrorBuilder<T>
withTrace(
PosIdx
pos,
const
std::string_view text) &&;
80
81
[[gnu::noinline]]
EvalErrorBuilder<T>
withSuggestions(
Suggestions
& s) &&;
82
83
[[gnu::noinline]]
EvalErrorBuilder<T>
withFrame(
const
Env
& e,
const
Expr
& ex) &&;
84
85
[[gnu::noinline]]
EvalErrorBuilder<T>
addTrace(
PosIdx
pos,
HintFmt
hint) &&;
86
87
template
<
typename
...
Args
>
88
[[gnu::noinline]]
EvalErrorBuilder<T>
89
addTrace(
PosIdx
pos, std::string_view formatString,
const
Args
&... formatArgs) &&;
90
94
[[gnu::noinline, gnu::noreturn]]
void
debugThrow(
NeverAsync
= {}) &&;
95
99
[[gnu::noinline, gnu::noreturn]]
void
throw_() &&;
100
};
101
102
}
box_ptr.hh
nix::Args
Definition
args.hh:31
nix::EvalErrorBuilder
Definition
eval-error.hh:59
nix::EvalError
Definition
eval-error.hh:23
nix::HintFmt
Definition
fmt.hh:157
nix::PosIdx
Definition
pos-idx.hh:9
nix::PosTable
Definition
pos-table.hh:16
nix::Suggestions
Definition
suggestions.hh:29
nix::box_ptr
Definition
box_ptr.hh:16
error.hh
This file defines two main structs/classes used in nix error handling.
pos-idx.hh
pos-table.hh
nix::DebugState
Definition
eval.hh:153
nix::Env
Definition
eval.hh:118
nix::Expr
Definition
nixexpr.hh:47
nix::InvalidPathError
Definition
eval-error.hh:48
nix::NeverAsync
Definition
types.hh:166
nix::Value
Definition
value.hh:191
types.hh
nix::Path
std::string Path
Definition
types.hh:28
lix
libexpr
eval-error.hh
Generated by
1.10.0