Describe the errno an error stores, not the current one

The description looked up the message of whatever errno was set when
the description was built, so an error printed later read
"Success (errno 28)".
This commit is contained in:
T. R. Bernstein
2026-09-19 00:45:22 +02:00
parent 21f096aede
commit 3215d2eb5a
3 changed files with 16 additions and 10 deletions
@@ -0,0 +1,11 @@
import Testing
@testable import Inotify
@Suite("Error Description")
struct InotifyErrorTests {
@Test func describesTheStoredErrnoAndNotTheCurrentOne() {
let error = InotifyError.addWatchFailed(path: "/watched", errno: 28)
#expect(error.description == "inotify_add_watch failed for '/watched': No space left on device (errno 28)")
}
}