mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(apple): Don't log certain security errors in debug (#7764)
When building / testing the Apple clients locally, OS code signing and security requirements can cause certain types of errors to throw. We still want to see these in the console, but not necessary capture them to Sentry.
This commit is contained in:
@@ -53,7 +53,10 @@ public final class Log {
|
||||
public static func error(_ err: Error) {
|
||||
self.logger.error("\(err.localizedDescription, privacy: .public)")
|
||||
logWriter?.write(severity: .error, message: err.localizedDescription)
|
||||
Telemetry.capture(err)
|
||||
|
||||
if shouldCaptureError(err) {
|
||||
Telemetry.capture(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the size in bytes of the provided directory, calculated by summing
|
||||
@@ -97,6 +100,19 @@ public final class Log {
|
||||
|
||||
try FileManager.default.removeItem(at: directory)
|
||||
}
|
||||
|
||||
// Don't capture certain kinds of IPC and security errors in DEBUG builds
|
||||
// because these happen often due to code signing requirements.
|
||||
private static func shouldCaptureError(_ err: Error) -> Bool {
|
||||
#if DEBUG
|
||||
if let err = err as? VPNConfigurationManagerError,
|
||||
case VPNConfigurationManagerError.noIPCData = err {
|
||||
return false
|
||||
}
|
||||
#endif
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private final class LogWriter {
|
||||
|
||||
@@ -16,6 +16,7 @@ enum VPNConfigurationManagerError: Error {
|
||||
case cannotLoad
|
||||
case decodeIPCDataFailed
|
||||
case invalidStatusChange
|
||||
case noIPCData
|
||||
|
||||
var localizedDescription: String {
|
||||
switch self {
|
||||
@@ -27,6 +28,8 @@ enum VPNConfigurationManagerError: Error {
|
||||
return "NEVPNStatusDidChange notification doesn't seem to be valid."
|
||||
case .cannotLoad:
|
||||
return "Could not load VPN configurations!"
|
||||
case .noIPCData:
|
||||
return "No IPC data returned from the XPC connection!"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,7 +372,7 @@ public class VPNConfigurationManager {
|
||||
guard let data = data
|
||||
else {
|
||||
continuation
|
||||
.resume(throwing: VPNConfigurationManagerError.decodeIPCDataFailed)
|
||||
.resume(throwing: VPNConfigurationManagerError.noIPCData)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -399,7 +402,7 @@ public class VPNConfigurationManager {
|
||||
) { data in
|
||||
guard let data = data
|
||||
else {
|
||||
errorHandler(VPNConfigurationManagerError.decodeIPCDataFailed)
|
||||
errorHandler(VPNConfigurationManagerError.noIPCData)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user