             print("Cannot parse message"); return
         }
         guard let handler = commands[msg.command!] else {
-            print("Command not registered: \(msg.command)"); return
+            let error = "Command not registered: \(msg.command!)"
+            BridgeCommand(msg, commander: self)
+                .error(args: error)
+            print(error)
+            return
         }
         handler(BridgeCommand(msg, commander: self))
     }

        
        super.init()
        if let filepath = Bundle(for: type(of: self)).path(forResource: "SwiftBridgeCommander", ofType: "js") {            do {
                let contents = try String(contentsOfFile: filepath)
                self.webView.configuration.userContentController.addUserScript(WKUserScript(source: contents, injectionTime: .atDocumentEnd, forMainFrameOnly: false))
                self.webView.configuration.userContentController.add(self, name: commandPrefix)
            } catch {
               print("Error occured")
            }
        } else {
            print("Error script not found")

import WebKit

public class SwiftBridgeCommander : NSObject, WKScriptMessageHandler {
    let messageHandlerName = "__SWIFT_BRIDGE_COMMANDER"
    let bridgeScriptObject = "BridgeCommander"
    
    let webView: WKWebView
    var commands = [String: CommandHandler]()
