2015-11-14 29 views
1

我一直在運行這段代碼很長一段時間,但突然它拋出錯誤下面,我怎麼突然得到這個沒有編輯代碼?以及我在do/catch語句中做錯了什麼?突然得到do/catch錯誤

func addInput(device: AVCaptureDevice) { 

    do { 
     captureSession.addInput(try AVCaptureDeviceInput(device: device)) 

    } catch let err as NSError { 
     print(err) 
    } 

} 

錯誤

Errors thrown from here are not handled because the enclosing catch is not exhaustive 
+0

您沒有顯示錯誤。 – Mundi

+0

對不起!!!添加 –

回答

1

有帶或不帶一個errorcatch的可能性。只需添加一條新的catch語句。

do    { /* try something */ } 
catch let error { print((error as NSError)) } 
catch   { print("No error") } 

如果您在第二行使用版本,則可能不需要第三行。