---
title: "error(_:userInfo:url:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/cocoaerror/error(_:userinfo:url:)"
---

# error(_:userInfo:url:)

## Declaration

```swift
static func error(_ code: CocoaError.Code, userInfo: [AnyHashable : Any]? = nil, url: URL? = nil) -> any Error
```
