---
title: "nil-error-return"
description: "Detect nil errors returned from branches that prove an error is non-nil."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# nil-error-return

**Default severity:** `error`

Reports explicit nil error results inside a branch entered because an error is
non-nil. Returning success there silently discards the failure.

## Bad

```go
if err != nil { return nil, nil }
```

## Good

```go
if err != nil { return nil, err }
```

Source: https://strider.gempir.com/analyzers/nil-error-return/index.mdx
