From 61a0843bb5fd55daf1520b5d5b21560ec0042e68 Mon Sep 17 00:00:00 2001 From: Gregorio Litenstein Date: Sun, 5 Feb 2017 18:47:31 -0300 Subject: [PATCH] Prevent occasional errors caused by unwrapping nil --- Sources/getHandler.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/getHandler.swift b/Sources/getHandler.swift index b32fb64..bb02a27 100644 --- a/Sources/getHandler.swift +++ b/Sources/getHandler.swift @@ -89,7 +89,9 @@ class ReadCommand: OptionCommand { break } - - if (nil != handler) { print(handler!) } else { throw CLIError.error(("An incompatible combination was used, or no application is registered to handle \(self.contentType!)")) } + let arg: String + if (self.contentType != nil) { arg = self.contentType! } + else { arg = "" } + if (nil != handler) { print(handler!) } else { throw CLIError.error(("An incompatible combination was used, or no application is registered to handle \(arg)")) } } }