---
title: "flatMapError(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/result/flatmaperror(_:)"
---

# flatMapError(_:)

Returns a new result, mapping any failure value using the given transformation and unwrapping the produced result.

## Declaration

```swift
consuming func flatMapError<NewFailure>(_ transform: (Failure) -> Result<Success, NewFailure>) -> Result<Success, NewFailure> where NewFailure : Error
```

## Parameters

- `transform`: A closure that takes the failure value of the instance.

## Return Value

Return Value A Result instance, either from the closure or the previous .success.

## See Also

### Transforming a Result

- [map(_:)](swift/result/map(_:).md)
- [mapError(_:)](swift/result/maperror(_:).md)
- [flatMap(_:)](swift/result/flatmap(_:).md)
