Skip to content

Commit 32d6efb

Browse files
committed
Ensure all .invalidArgument errors are converted into GRPCStatus
1 parent 8633fe6 commit 32d6efb

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

vminitd/Sources/vminitd/Server+GRPC.swift

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
432432
"configuration": "\(request.configuration.count)",
433433
])
434434

435-
if !request.hasContainerID {
436-
throw ContainerizationError(
437-
.invalidArgument,
438-
message: "processes in the root of the vm not implemented"
439-
)
440-
}
441-
442435
do {
436+
if !request.hasContainerID {
437+
throw ContainerizationError(
438+
.invalidArgument,
439+
message: "processes in the root of the vm not implemented"
440+
)
441+
}
442+
443443
var ociSpec = try JSONDecoder().decode(
444444
ContainerizationOCI.Spec.self,
445445
from: request.configuration
@@ -536,14 +536,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
536536
"signal": "\(request.signal)",
537537
])
538538

539-
if !request.hasContainerID {
540-
throw ContainerizationError(
541-
.invalidArgument,
542-
message: "processes in the root of the vm not implemented"
543-
)
544-
}
545-
546539
do {
540+
if !request.hasContainerID {
541+
throw ContainerizationError(
542+
.invalidArgument,
543+
message: "processes in the root of the vm not implemented"
544+
)
545+
}
546+
547547
let ctr = try await self.state.get(container: request.containerID)
548548
try await ctr.kill(execID: request.id, request.signal)
549549

@@ -584,14 +584,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
584584
"containerID": "\(request.containerID)",
585585
])
586586

587-
if !request.hasContainerID {
588-
throw ContainerizationError(
589-
.invalidArgument,
590-
message: "processes in the root of the vm not implemented"
591-
)
592-
}
593-
594587
do {
588+
if !request.hasContainerID {
589+
throw ContainerizationError(
590+
.invalidArgument,
591+
message: "processes in the root of the vm not implemented"
592+
)
593+
}
594+
595595
let ctr = try await self.state.get(container: request.containerID)
596596

597597
// Are we trying to delete the container itself?
@@ -640,14 +640,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
640640
"containerID": "\(request.containerID)",
641641
])
642642

643-
if !request.hasContainerID {
644-
throw ContainerizationError(
645-
.invalidArgument,
646-
message: "processes in the root of the vm not implemented"
647-
)
648-
}
649-
650643
do {
644+
if !request.hasContainerID {
645+
throw ContainerizationError(
646+
.invalidArgument,
647+
message: "processes in the root of the vm not implemented"
648+
)
649+
}
650+
651651
let ctr = try await self.state.get(container: request.containerID)
652652
let pid = try await ctr.start(execID: request.id)
653653

@@ -693,14 +693,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
693693
"containerID": "\(request.containerID)",
694694
])
695695

696-
if !request.hasContainerID {
697-
throw ContainerizationError(
698-
.invalidArgument,
699-
message: "processes in the root of the vm not implemented"
700-
)
701-
}
702-
703696
do {
697+
if !request.hasContainerID {
698+
throw ContainerizationError(
699+
.invalidArgument,
700+
message: "processes in the root of the vm not implemented"
701+
)
702+
}
703+
704704
let ctr = try await self.state.get(container: request.containerID)
705705
let size = Terminal.Size(
706706
width: UInt16(request.columns),
@@ -734,14 +734,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
734734
"containerID": "\(request.containerID)",
735735
])
736736

737-
if !request.hasContainerID {
738-
throw ContainerizationError(
739-
.invalidArgument,
740-
message: "processes in the root of the vm not implemented"
741-
)
742-
}
743-
744737
do {
738+
if !request.hasContainerID {
739+
throw ContainerizationError(
740+
.invalidArgument,
741+
message: "processes in the root of the vm not implemented"
742+
)
743+
}
744+
745745
let ctr = try await self.state.get(container: request.containerID)
746746
let exitStatus = try await ctr.wait(execID: request.id)
747747

@@ -788,14 +788,14 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
788788
"containerID": "\(request.containerID)",
789789
])
790790

791-
if !request.hasContainerID {
792-
throw ContainerizationError(
793-
.invalidArgument,
794-
message: "processes in the root of the vm not implemented"
795-
)
796-
}
797-
798791
do {
792+
if !request.hasContainerID {
793+
throw ContainerizationError(
794+
.invalidArgument,
795+
message: "processes in the root of the vm not implemented"
796+
)
797+
}
798+
799799
let ctr = try await self.state.get(container: request.containerID)
800800

801801
try await ctr.closeStdin(execID: request.id)

0 commit comments

Comments
 (0)