Home Explore Blog Models CI



nushell

22th chunk of `contributor-book/plugin_protocol_reference.md`
c7667e4517dc177c1df60deb0d8e75538dbc232e511afe9000000001000009b5
The `Unknown` type is used by Nu to represent the output of external commands if they are not passed through [`into string`](/commands/docs/into_string.md) or [`into binary`](/commands/docs/into_binary.md) to explicitly set their type. A command that declares an output type of exclusively either `string` or `binary` **must** explicitly type its output byte streams appropriately, to ensure they coerce to the correct type, rather than using `Unknown`.

Example:

```json
{
  "ByteStream": {
    "id": 7,
    "span": {
      "start": 49011,
      "end": 49027
    },
    "type": "String"
  }
}
```

### `LabeledError`

[Documentation](https://docs.rs/nu-protocol/latest/nu_protocol/struct.LabeledError.html)

A flexible, generic error type, with any number of labeled spans.

| Field      | Type                  | Description                                                                                                    |
| ---------- | --------------------- | -------------------------------------------------------------------------------------------------------------- |
| **msg**    | string                | The main error message to show at the top of the error.                                                        |
| **labels** | `ErrorLabel` array?   | Spans and messages to label the error in the source code.                                                      |
| **code**   | string?               | A unique machine- and search-friendly code that can be matched against, e.g. `nu::shell::missing_config_value` |
| **url**    | string?               | A URL that links to additional information about the error.                                                    |
| **help**   | string?               | Additional help for the error, usually a hint about what the user might try.                                   |
| **inner**  | `LabeledError` array? | Additional errors referenced by the error, possibly the cause(s) of this error.                                |

Most of the fields are not required - only `msg` must be present. `ErrorLabel` (in the `labels` array) is as follows:

| Field    | Type            | Description                                                 |
| -------- | --------------- | ----------------------------------------------------------- |
| **text** | string          | The message for the label.                                  |
| **span** | [`Span`](#span) | The span in the source code that the label should point to. |

Title: ByteStreamType 'Unknown' and LabeledError Details
Summary
This section describes the 'Unknown' type in `ByteStream` and when it should be used. It also provides a detailed breakdown of the `LabeledError` structure, including its fields such as 'msg', 'labels', 'code', 'url', 'help', and 'inner', along with a description of the `ErrorLabel` structure within the 'labels' array.