Skip to content

Commit 7a089de

Browse files
committed
Print error when creation of a sourcekitd request from YAML fails in the debug run-sourcekitd-request command
1 parent d11c101 commit 7a089de

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/Diagnose/RunSourcekitdRequestCommand.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ package struct RunSourceKitdRequestCommand: AsyncParsableCommand {
7676

7777
let request = try requestString.cString(using: .utf8)!.withUnsafeBufferPointer { buffer in
7878
var error: UnsafeMutablePointer<CChar>?
79-
let req = sourcekitd.api.request_create_from_yaml(buffer.baseAddress!, &error)!
79+
let req = sourcekitd.api.request_create_from_yaml(buffer.baseAddress!, &error)
8080
if let error {
81-
throw GenericError("Failed to parse sourcekitd request from JSON: \(String(cString: error))")
81+
throw GenericError("Failed to parse sourcekitd request from YAML: \(String(cString: error))")
82+
}
83+
guard let req else {
84+
throw GenericError("Failed to parse request from YAML but did not produce error")
8285
}
8386
return req
8487
}

0 commit comments

Comments
 (0)