Skip to content

Commit 2d3407e

Browse files
committed
Throw an error if a URL's reported path is not absolute
1 parent 1d66c4f commit 2d3407e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/SWBUtil/URL.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ extension URL {
2828
throw FileURLError.notRepresentable(self)
2929
}
3030
let fp = Path(String(cString: cString))
31-
precondition(fp.isAbsolute, "path '\(fp.str)' is not absolute")
31+
guard fp.isAbsolute else {
32+
throw FileURLError.pathNotAbsolute(self)
33+
}
3234
return fp
3335
}
3436
}
@@ -37,4 +39,5 @@ extension URL {
3739

3840
fileprivate enum FileURLError: Error {
3941
case notRepresentable(URL)
42+
case pathNotAbsolute(URL)
4043
}

0 commit comments

Comments
 (0)