blob: de4265c256e738b759aedf700f60aba52519172b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// SPDX-License-Identifier: MIT
// Copyright © 2018-2020 WireGuard LLC. All Rights Reserved.
import NetworkExtension
class ErrorNotifier {
let activationAttemptId: String?
init(activationAttemptId: String?) {
self.activationAttemptId = activationAttemptId
ErrorNotifier.removeLastErrorFile()
}
func notify(_ error: PacketTunnelProviderError) {
guard let activationAttemptId = activationAttemptId, let lastErrorFilePath = FileManager.networkExtensionLastErrorFileURL?.path else { return }
let errorMessageData = "\(activationAttemptId)\n\(error)".data(using: .utf8)
FileManager.default.createFile(atPath: lastErrorFilePath, contents: errorMessageData, attributes: nil)
}
static func removeLastErrorFile() {
if let lastErrorFileURL = FileManager.networkExtensionLastErrorFileURL {
_ = FileManager.deleteFile(at: lastErrorFileURL)
}
}
}
|