Skip to content

Commit 2f7f6c1

Browse files
committed
don’t throw from main in UnidocBuild
1 parent c4cf9ef commit 2f7f6c1

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Sources/System/SystemProcess.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#if os(Linux)
1+
#if canImport(Glibc)
22
import Glibc
3-
#elseif os(macOS)
3+
#elseif canImport(Darwin)
44
import Darwin
55
#else
66
#error("unsupported platform")
@@ -115,3 +115,20 @@ extension SystemProcess
115115
}
116116
}
117117
}
118+
extension SystemProcess
119+
{
120+
@MainActor
121+
public static
122+
func `do`(_ operation:() async throws -> Void) async
123+
{
124+
do
125+
{
126+
try await operation()
127+
}
128+
catch let error
129+
{
130+
print(error)
131+
exit(1)
132+
}
133+
}
134+
}

Sources/UnidocBuild/Main.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import UnidocAPI
99
enum Main
1010
{
1111
static
12-
func main() async throws
12+
func main() async
13+
{
14+
await SystemProcess.do(Self._main)
15+
}
16+
17+
private static
18+
func _main() async throws
1319
{
1420
let options:Options = try .parse()
1521

0 commit comments

Comments
 (0)