Skip to content

Commit 03f4a22

Browse files
committed
Improved validation for PrinterBuilder
1 parent 6a7c6d2 commit 03f4a22

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

lib/data/dto/machine/printer.dart

+24-9
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,31 @@ class PrinterBuilder {
6060
Map<String, Led> leds = {};
6161

6262
Printer build() {
63-
if (toolhead == null ||
64-
printFan == null ||
65-
gCodeMove == null ||
66-
motionReport == null ||
67-
displayStatus == null ||
68-
print == null ||
69-
configFile == null ||
70-
virtualSdCard == null) {
71-
throw const MobilerakerException('Missing field');
63+
if (toolhead == null) {
64+
throw const MobilerakerException('Missing field: toolhead');
7265
}
66+
if (printFan == null) {
67+
throw const MobilerakerException('Missing field: printFan');
68+
}
69+
if (gCodeMove == null) {
70+
throw const MobilerakerException('Missing field: gCodeMove');
71+
}
72+
if (motionReport == null) {
73+
throw const MobilerakerException('Missing field: motionReport');
74+
}
75+
if (displayStatus == null) {
76+
throw const MobilerakerException('Missing field: displayStatus');
77+
}
78+
if (print == null) {
79+
throw const MobilerakerException('Missing field: print');
80+
}
81+
if (configFile == null) {
82+
throw const MobilerakerException('Missing field: configFile');
83+
}
84+
if (virtualSdCard == null) {
85+
throw const MobilerakerException('Missing field: virtualSdCard');
86+
}
87+
7388
var printer = Printer(
7489
toolhead: toolhead!,
7590
extruders: extruders,

0 commit comments

Comments
 (0)