func _run_main()

in core/swift51Action/swiftbuild.py.launcher.swift [101:123]


func _run_main<Out: Encodable>(mainFunction: ( @escaping (Out?, Error?) -> Void) -> Void, json: Data) {
    let resultHandler = { (out: Out?, error: Error?) in
        if let error = error {
            _whisk_print_error(message: "Action handler callback returned an error:", error: error)
            return
        }
        guard let out = out else {
            _whisk_print_error(message: "Action handler callback did not return response or error.", error: nil)
            return
        }
        do {
            let jsonData = try Whisk.jsonEncoder.encode(out)
            _whisk_print_result(jsonData: jsonData)
        } catch let error as EncodingError {
            _whisk_print_error(message: "JSONEncoder failed to encode Codable type to JSON string:", error: error)
            return
        } catch {
            _whisk_print_error(message: "Failed to execute action handler with error:", error: error)
            return
        }
    }
    let _ = mainFunction(resultHandler)
}