1 /**
2  * Copyright: Copyright Jason White, 2016
3  * License:   MIT
4  * Authors:   Jason White
5  *
6  * Description:
7  * Defines exception classes used in button
8  *
9  * Definitions of exception classes are separated into own module
10  * to break module import cycles and reduce overall module inter-depdendency
11  */
12 module button.exceptions;
13 
14 import std.exception : basicExceptionCtors;
15 
16 /**
17  * Thrown when an invalid command name is given to $(D runCommand).
18  */
19 class InvalidCommand : Exception
20 {
21     mixin basicExceptionCtors;
22 }
23 
24 /**
25  * Thrown if a command fails.
26  */
27 class CommandError : Exception
28 {
29     int exitCode;
30 
31     this(int exitCode, string file = __FILE__, int line = __LINE__)
32     {
33         import std.format : format;
34 
35         super("Command failed with exit code %d".format(exitCode), file, line);
36 
37         this.exitCode = exitCode;
38     }
39 }
40 
41 /**
42  * Exception that is thrown on invalid GCC deps syntax.
43  */
44 class MakeParserError : Exception
45 {
46     mixin basicExceptionCtors;
47 }
48 
49 /**
50  * Thrown when an edge does not exist.
51  */
52 class InvalidEdge : Exception
53 {
54     mixin basicExceptionCtors;
55 }
56 
57 /**
58  * An exception relating to the build.
59  */
60 class BuildException : Exception
61 {
62     mixin basicExceptionCtors;
63 }
64 
65 /**
66  * Thrown if a task fails.
67  */
68 class TaskError : Exception
69 {
70     mixin basicExceptionCtors;
71 }