---
title: "documentCameraViewController(_:didFailWithError:)"
framework: visionkit
role: symbol
role_heading: Instance Method
path: "visionkit/vndocumentcameraviewcontrollerdelegate/documentcameraviewcontroller(_:didfailwitherror:)"
---

# documentCameraViewController(_:didFailWithError:)

Tells the delegate that document scanning failed while the camera view controller was active.

## Declaration

```swift
optional func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFailWithError error: any Error)
```

## Parameters

- `controller`: The document camera view controller that failed.
- `error`: The error containing the reason for failure.

## See Also

### Determining scan results

- [documentCameraViewController(_:didFinishWith:)](visionkit/vndocumentcameraviewcontrollerdelegate/documentcameraviewcontroller(_:didfinishwith:).md)
- [documentCameraViewControllerDidCancel(_:)](visionkit/vndocumentcameraviewcontrollerdelegate/documentcameraviewcontrollerdidcancel(_:).md)
