mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 17:29:23 +00:00
Convert Error Log to .xib. De-dupe some common code.
This commit is contained in:
1 parent
62ea1f32d3
commit
35267d7d30
7 files changed
+333
-291
No files matched your search
@@ -36,3 +36,28 @@ public struct ErrorLogUserInfoKey {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
public extension ErrorLogEntry {
|
||||
|
||||
/// Build an entry from an `.appDidEncounterError` notification. Returns nil if any required
|
||||
/// key is missing. The id is 0 — the entry has not yet been persisted.
|
||||
init?(notification: Notification) {
|
||||
guard let userInfo = notification.userInfo,
|
||||
let errorMessage = userInfo[ErrorLogUserInfoKey.errorMessage] as? String,
|
||||
let sourceName = userInfo[ErrorLogUserInfoKey.sourceName] as? String,
|
||||
let sourceID = userInfo[ErrorLogUserInfoKey.sourceID] as? Int else {
|
||||
return nil
|
||||
}
|
||||
self.init(
|
||||
id: 0,
|
||||
date: Date(),
|
||||
sourceName: sourceName,
|
||||
sourceID: sourceID,
|
||||
operation: userInfo[ErrorLogUserInfoKey.operation] as? String ?? "",
|
||||
fileName: userInfo[ErrorLogUserInfoKey.fileName] as? String ?? "",
|
||||
functionName: userInfo[ErrorLogUserInfoKey.functionName] as? String ?? "",
|
||||
lineNumber: userInfo[ErrorLogUserInfoKey.lineNumber] as? Int ?? 0,
|
||||
errorMessage: errorMessage
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user