From e90bf7c9dbd1beb2835db98da2910f83a0631ca3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 5 Jun 2020 16:23:11 -0400 Subject: [PATCH] Catch error for debugging --- MVMCoreUI/Containers/NavigationController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index bac5817c..8e7279ce 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -92,9 +92,13 @@ import UIKit } /// Convenience setter for legacy files - public static func set(navigationController: UINavigationController, navigationJSON: [String: Any], viewController: UIViewController) { - let moleculeName = ModelRegistry.getType(for: navigationJSON.stringForkey(KeyMoleculeName), with: MoleculeModelProtocol.self) - guard let barModel = try? moleculeName?.decode(jsonDict: navigationJSON) as? (MoleculeModelProtocol & NavigationItemModelProtocol) else { return } + public static func set(navigationController: UINavigationController, navigationJSON: [String: Any], viewController: UIViewController) throws { + guard let moleculeName = ModelRegistry.getType(for: navigationJSON.stringForkey(KeyMoleculeName), with: MoleculeModelProtocol.self) else { + throw ModelRegistry.Error.keyNotFound + } + guard let barModel = try moleculeName.decode(jsonDict: navigationJSON) as? (MoleculeModelProtocol & NavigationItemModelProtocol) else { + throw ModelRegistry.Error.decoderOther(message: "Model not a bar model") + } set(navigationController: navigationController, navigationItemModel: barModel, viewController: viewController) } }