---
title: "fetchLastDisconnectError(completionHandler:)"
framework: networkextension
role: symbol
role_heading: Instance Method
path: "networkextension/nevpnconnection/fetchlastdisconnecterror(completionhandler:)"
---

# fetchLastDisconnectError(completionHandler:)

Retrives the most recent error that caused the VPN to disconnect.

## Declaration

```swift
func fetchLastDisconnectError(completionHandler handler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func fetchLastDisconnectError() async throws
```

## Parameters

- `handler`: An error handler that receives the last disconnect error as a parameter.

## Discussion

Discussion If VPN system (including the IPsec client) generated the error, then the error uses the NEVPNConnectionErrorDomain error domain. If the error came from a tunnel provider app extension instead, then the error is the NSError that the provider passed when disconnecting the tunnel.

## See Also

### Handling errors

- [NEVPNConnectionErrorDomain](networkextension/nevpnconnectionerrordomain.md)
- [NEVPNConnectionError](networkextension/nevpnconnectionerror.md)
