removed try

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-05-10 12:16:30 -05:00
parent 3f0450547a
commit a7e32f3ca4
2 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ extension JSONDecoder {
/// Helper method to initialize a JSONDecoder
/// - Parameter delegateObject: Delegate Object
/// - Returns: JSONDecoder
public class func create(delegateObject: DelegateObject? = nil) throws -> JSONDecoder {
public class func create(delegateObject: DelegateObject? = nil) -> JSONDecoder {
let decoder = JSONDecoder()
decoder.add(value: DecodingContext(), for: .contextKey)
if let delegateObject = delegateObject {

View File

@ -16,7 +16,7 @@ extension JSONDecoder: AnyDecoder {}
extension PropertyListDecoder: AnyDecoder {}
extension Data {
public func decode<T: Decodable>(using decoder: AnyDecoder = JSONDecoder(), delegateObject: DelegateObject? = nil) throws -> T {
public func decode<T: Decodable>(using decoder: AnyDecoder = JSONDecoder.create(), delegateObject: DelegateObject? = nil) throws -> T {
if let decoder = decoder as? JSONDecoder {
return try decoder.decode(T.self, from: self, delegateObject: delegateObject)
} else {
@ -52,7 +52,7 @@ extension Decodable {
public static func decode(jsonDict: [String: Any], delegateObject: DelegateObject? = nil) throws -> Self {
let jsonData = try JSONSerialization.data(withJSONObject: jsonDict)
do {
let decoder = try JSONDecoder.create(delegateObject: delegateObject)
let decoder = JSONDecoder.create(delegateObject: delegateObject)
return try jsonData.decode(using: decoder)
} catch {
throw JSONError.other(error: error)