-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Deserializing SentryMechanism (#4746)
- Loading branch information
1 parent
1c53492
commit 6e024ed
Showing
3 changed files
with
72 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
Sources/Swift/Protocol/Codable/SentryMechanismCodable.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,31 @@ | ||
@_implementationOnly import _SentryPrivate | ||
import Foundation | ||
|
||
extension Mechanism: Decodable { | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case type | ||
case handled | ||
case synthetic | ||
case desc = "description" | ||
case data | ||
case helpLink = "help_link" | ||
case meta | ||
} | ||
|
||
required convenience public init(from decoder: any Decoder) throws { | ||
|
||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
let type = try container.decode(String.self, forKey: .type) | ||
self.init(type: type) | ||
self.desc = try container.decodeIfPresent(String.self, forKey: .desc) | ||
self.data = decodeArbitraryData { | ||
try container.decodeIfPresent([String: ArbitraryData].self, forKey: .data) | ||
} | ||
self.handled = try container.decodeIfPresent(NSNumberDecodableWrapper.self, forKey: .handled)?.value | ||
self.synthetic = try container.decodeIfPresent(NSNumberDecodableWrapper.self, forKey: .synthetic)?.value | ||
self.helpLink = try container.decodeIfPresent(String.self, forKey: .helpLink) | ||
self.meta = try container.decodeIfPresent(MechanismMeta.self, forKey: .meta) | ||
} | ||
} |
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