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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use crate::types::PlayerId;
use miette::Diagnostic;
use thiserror::Error;

#[derive(Error, Debug, Diagnostic)]
#[error("failed to find workspace!")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("correct settings.workspace_path to a valid directory")
)]
pub struct WorkspaceNotFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("missing mods/ folder from working directory")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("correct settings.workspace_path to a valid directory")
)]
pub struct MissingModsFolder {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to create factorio mods symlink")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("allow elevated access for symlink creating")
)]
pub struct ModSymlinkFailed {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to extract mods content to workspace")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("allow elevated access for symlink creating")
)]
pub struct ModExtractFailed {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to extract scripts to workspace")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("allow elevated access for symlink creating")
)]
pub struct PlansExtractFailed {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to find factorio binary")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("delete factorio folder as it is broken")
)]
pub struct FactorioBinaryNotFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to find instance")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct FactorioInstanceNotFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to find factorio saves folder")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct FactorioSavesNotFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to find factorio server settings")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct FactorioSettingsNotFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("failed to create factorio level")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct FactorioLevelFailed {}

#[derive(Error, Debug, Diagnostic)]
#[error("factorio instance already running")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("stop running instance first")
)]
pub struct FactorioAlreadyStarted {}

#[derive(Error, Debug, Diagnostic)]
#[error("player not found")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("provide correct player id")
)]
pub struct RconPlayerNotFound {
    pub player_id: PlayerId,
}

#[derive(Error, Debug, Diagnostic)]
#[error("player still blocks placement")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconPlayerBlockesPlacement {}

#[derive(Error, Debug, Diagnostic)]
#[error("player blocks placement in all directions")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconPlayerBlockesAllPlacement {}

#[derive(Error, Debug, Diagnostic)]
#[error("Unexpected Empty Response")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconUnexpectedEmptyResponse {}

#[derive(Error, Debug, Diagnostic)]
#[error("Unexpected Output")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconUnexpectedOutput {
    pub output: String,
}

#[derive(Error, Debug, Diagnostic)]
#[error("Unexpected Response")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconError {
    pub message: String,
}

#[derive(Error, Debug, Diagnostic)]
#[error("no action result received in time")]
#[diagnostic(code(factorio::workspace::not_found), help("read logs"))]
pub struct RconTimeout {}

#[derive(Error, Debug, Diagnostic)]
#[error("max radius: 3000")]
#[diagnostic(
    code(factorio::workspace::not_found),
    help("use lower value for radius")
)]
pub struct RconRadiusLimitReached {
    pub limit: u32,
}

#[derive(Error, Debug, Diagnostic)]
#[error("could not find water")]
#[diagnostic(code(factorio::workspace::not_found), help("build somewhere else"))]
pub struct RconNoWaterFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("fromPosition is blocked")]
#[diagnostic(code(factorio::workspace::not_found), help("build somewhere else"))]
pub struct RconSourcePositionBlocked {}

#[derive(Error, Debug, Diagnostic)]
#[error("toPosition is blocked")]
#[diagnostic(code(factorio::workspace::not_found), help("build somewhere else"))]
pub struct RconTargetPositionBlocked {}

#[derive(Error, Debug, Diagnostic)]
#[error("no path found")]
#[diagnostic(code(factorio::workspace::not_found), help("build somewhere else"))]
pub struct RconNoPathFound {}

#[derive(Error, Debug, Diagnostic)]
#[error("invalid rect: expected A,B;C,D like 1.2,3.4;5.6,7.8")]
#[diagnostic(code(factorio::workspace::not_found), help("fix rect formatting"))]
pub struct RectInvalid {
    pub invalid_input: String,
}

#[derive(Error, Debug, Diagnostic)]
#[error("player does not have item in inventory")]
#[diagnostic(code(factorio::workspace::not_found), help("fix logic"))]
pub struct PlayerMissingItem {
    pub player_id: PlayerId,
    pub item: String,
}