> For the complete documentation index, see [llms.txt](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/resultoption/maperror.md).

# mapError

### ResultOption.mapError

Namespace: `FsToolkit.ErrorHandling`

Function Signature:

```fsharp
('errorInput -> 'errorOutput) -> Result<'ok option, 'errorInput> -> Result<'ok option, 'errorOutput>
```

### Examples

#### Example 1

From the [ResultOption.map](/fstoolkit-errorhandling/fstoolkit.errorhandling/resultoption/map.md#example-3) example, if we want to map the error part alone, we can do it as below:

```fsharp
// string -> int
let getErrorCode (message: string) =
    match message with
    | "bad things happened" -> 1
    | _ -> 0

let result : Result<string option, int> =
  Error "bad things happened" // Result<string option, string>
  |> ResultOption.mapError getErrorCode // Result<string option, int>

// Error 1
```
