---
title: error
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/urlsessiontask/error
---

# error

An error object that indicates why the task failed.

## Declaration

```swift
var error: (any Error)? { get }
```

## Discussion

Discussion This value is nil if the task is still active or if the transfer completed successfully.

## See Also

### Obtaining general task information

- [currentRequest](foundation/urlsessiontask/currentrequest.md)
- [originalRequest](foundation/urlsessiontask/originalrequest.md)
- [response](foundation/urlsessiontask/response.md)
- [taskDescription](foundation/urlsessiontask/taskdescription.md)
- [taskIdentifier](foundation/urlsessiontask/taskidentifier.md)
