Skip to content

Commit

Permalink
Updated POSIXError
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Oct 30, 2018
1 parent bbac385 commit 07c6f9b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Sources/BluetoothLinux/DeviceRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ internal func HCISendRequest <Command: HCICommand> (_ deviceDescriptor: CInt,

// poll timed out
guard pollStatus != 0
else { throw restoreFilter(POSIXError(code: .ETIMEDOUT)) }
else { throw restoreFilter(POSIXError(.ETIMEDOUT)) }

// decrement timeout (why?)
timeout -= 10
Expand Down Expand Up @@ -420,7 +420,7 @@ internal func HCISendRequest <Command: HCICommand> (_ deviceDescriptor: CInt,
}

// throw timeout error
throw POSIXError(code: .ETIMEDOUT)
throw POSIXError(.ETIMEDOUT)
}

// MARK: - Internal Constants
Expand Down
2 changes: 1 addition & 1 deletion Sources/BluetoothLinux/HostController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal func HCIDeviceAddress(_ deviceIdentifier: UInt16) throws -> Address {
let deviceInfo = try HCIDeviceInfo(deviceIdentifier)

guard HCITestBit(HCI.DeviceFlag.up, deviceInfo.flags)
else { throw POSIXError(code: .ENETDOWN) }
else { throw POSIXError(.ENETDOWN) }

return deviceInfo.address
}
Expand Down
15 changes: 1 addition & 14 deletions Sources/BluetoothLinux/POSIXError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ internal extension POSIXError {
guard let code = POSIXError.Code(rawValue: POSIXError.Code.RawValue(errno))
else { return nil }

return self.init(code: code)
}

/// Creates `POSIXError` from error code.
init(code: POSIXError.Code) {

let nsError = NSError(
domain: NSPOSIXErrorDomain,
code: Int(code.rawValue),
userInfo: [
NSLocalizedDescriptionKey: String(cString: strerror(CInt(code.rawValue)), encoding: .ascii)!
])

self.init(_nsError: nsError)
return self.init(code)
}
}

0 comments on commit 07c6f9b

Please sign in to comment.