consul/ui/packages/consul-ui/app/components/error-state
hashicorp-copywrite[bot] 5fb9df1640
[COMPLIANCE] License changes (#18443)
* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* add missing license headers

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-11 09:12:13 -04:00
..
README.mdx ui: Various empty state improvements/fixups (#11892) 2021-12-21 06:49:18 +00:00
index.hbs [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00

README.mdx

# ErrorState

Consul UIs default 'error state' used when an error is returned form the
backend. This component used `EmptyState` internally, so please refer to that
for more details.

Using this component for all of our errors means we can show a consistent
error page for generic errors.

This component show slightly different visuals and copy depending on the
`status` of the error (the status is generally a HTTP error code).

Please note: The examples below use a `hash` for demonstration purposes, you'll
probably just be using an `error` object in real-life.

## Arguments

| Argument | Type | Default | Description |
| --- | --- | --- | --- |
| `login` | `Function` | `undefined` | A login action to call when the login button is pressed (if not provided no login button will be shown  |
| `error` | `Object` | `undefined` | 'Consul UI error shaped' JSON `{status: String, message: String, detail: String}` |

Specifically 403 errors **always** use the same header/body copy, this is hardcoded in and not currently overridable.

```hbs preview-template
<ErrorState
  @error={{hash status='403'}}
/>
```

Other StatusCodes have a global default text but these *are* overridable by using the message/detail properties of the Consul UI shaped errors.

```hbs preview-template
<ErrorState
  @error={{hash
    status='404'
    message="`message` is what is shown in the header"
    detail="`detail` is what shown in the body"
  }}
/>
```

As with `EmptyState` you can optionally chose to show a login button using the
`@login` argument.

```hbs preview-template
<ErrorState
  @error={{hash status='403'}}
  @login={{noop}}
/>
```