         guard let fromPattern = fromPattern else {
             return (nil, nil)
         }
+
+        guard let keyRegex = namedCaptureRegex else {
+            Log.error("RouteRegex has invalid state: missing keyRegex")
+            return (nil, nil)
+        }
+        guard let nonKeyRegex = unnamedCaptureRegex else {
+            Log.error("RouteRegex element has invalid state: missing nonKeyRegex")
+            return (nil, nil)
+        }
+
         var pattern = fromPattern
         var regexStr = "^"
         var keys = [String]()

        }
        
        for path in paths {
            var status = false
            (regexStr, keys, nonKeyIndex, status) =
                handlePath(path, regexStr: regexStr, keys: keys, nonKeyIndex: nonKeyIndex)
            if !status {
                return (nil, nil)
            }
        }

        regexStr.append("(?:/(?=$))?")

                regexStr.append("/\(path)")
            }

            return (regexStr, keys, nonKeyIndex)
    }
}
