-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Decodable/Deserializing of SentryException.
- Loading branch information
1 parent
d408cb1
commit 2890581
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Sources/Swift/Protocol/Codable/SentryExceptionCodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@_implementationOnly import _SentryPrivate | ||
import Foundation | ||
|
||
extension Exception: Decodable { | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case value | ||
case type | ||
case mechanism | ||
case module | ||
case threadId = "thread_id" | ||
case stacktrace | ||
} | ||
|
||
required convenience public init(from decoder: any Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
let value = try container.decode(String.self, forKey: .value) | ||
let type = try container.decode(String.self, forKey: .type) | ||
|
||
self.init(value: value, type: type) | ||
|
||
self.mechanism = try container.decodeIfPresent(Mechanism.self, forKey: .mechanism) | ||
self.module = try container.decodeIfPresent(String.self, forKey: .module) | ||
self.threadId = try container.decodeIfPresent(NSNumberDecodableWrapper.self, forKey: .threadId)?.value | ||
self.stacktrace = try container.decodeIfPresent(SentryStacktrace.self, forKey: .stacktrace) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters