aboutsummaryrefslogtreecommitdiffstats
path: root/liblfjail/exec_error.hh
blob: fca8b0dd0d06724dfb2d53a384a821218f6d6cd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * This source code is released into the public domain.
 */

/*
 * Exceptions thrown when we fail to create an exec object.  The exec() itself
 * never throws, since it usually runs in a child process; instead, it just
 * prints a message to stderr and exits.
 */

#ifndef	LFJAIL_EXEC_ERROR_HH
#define	LFJAIL_EXEC_ERROR_HH

#include "generic_error.hh"

namespace lfjail {

/*
 * Generic error, what() should be descriptive.
 */
struct exec_error : generic_error {
	template<typename... Args>
	exec_error(std::format_string<Args...> fmt, Args &&...args)
		: generic_error(fmt, std::forward<Args>(args)...)
	{}
};

/*
 * We tried to execute a path or filename and the file was not found.
 */
struct executable_not_found : exec_error {
	std::string executable;

	executable_not_found(std::string executable_)
		: exec_error("{}: command not found", executable_)
		, executable(std::move(executable_))
	{}
};

} // namespace lfjail

#endif	// !LFJAIL_EXEC_ERROR_HH