Home Explore Blog CI



nushell

commands/docs/error_make.md
8f0d7f616f44122723e8d075c7fa0729ed097d860f20669400000003000005f1
---
title: error make
categories: |
  core
version: 0.104.0
core: |
  Create an error.
usage: |
  Create an error.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `error make` for [core](/commands/categories/core.md)

<div class='command-title'>Create an error.</div>

## Signature

```> error make {flags} (error_struct)```

## Flags

 -  `--unspanned, -u`: remove the origin label from the error

## Parameters

 -  `error_struct`: The error to create.


## Input/output types:

| input   | output |
| ------- | ------ |
| nothing | any    |
## Examples

Create a simple custom error
```nu
> error make {msg: "my custom error message"}

```

Create a more complex custom error
```nu
> error make {
        msg: "my custom error message"
        label: {
            text: "my custom label text"  # not mandatory unless $.label exists
            # optional
            span: {
                # if $.label.span exists, both start and end must be present
                start: 123
                end: 456
            }
        }
        help: "A help string, suggesting a fix to the user"  # optional
    }

```

Create a custom error for a custom command that shows the span of the argument
```nu
> def foo [x] {
        error make {
            msg: "this is fishy"
            label: {
                text: "fish right here"
                span: (metadata $x).span
            }
        }
    }

```

Chunks
437b6838 (1st chunk of `commands/docs/error_make.md`)
Title: error make: Create Custom Errors in Nushell
Summary
The `error make` command in Nushell allows users to create custom errors. It takes an error struct as input, which can include a message, label (with optional text and span), and help string. Flags can modify the error's behavior, such as removing the origin label.