---
title: "urlProtocol(_:didFailWithError:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlprotocolclient/urlprotocol(_:didfailwitherror:)"
---

# urlProtocol(_:didFailWithError:)

Tells the client that the load request failed due to an error.

## Declaration

```swift
func urlProtocol(_ protocol: URLProtocol, didFailWithError error: any Error)
```

## Parameters

- `protocol`: The URL protocol object sending the message.
- `error`: The error that caused the failure of the load request.

## See Also

### Indicating loading progress or failure

- [urlProtocol(_:didLoad:)](foundation/urlprotocolclient/urlprotocol(_:didload:).md)
- [urlProtocolDidFinishLoading(_:)](foundation/urlprotocolclient/urlprotocoldidfinishloading(_:).md)
