# HTTP error pages

**HTTP error pages** explain why a request failed and guide users to a meaningful next step.

## Usage

HTTP error pages are full-page messages for request failures such as missing pages, missing permissions, or server errors.

They are built with the [info page](<https://element.siemens.io/components/pages/info-page/>) component as the base layout.

![HTTP error pages](<../images/http-error-pages.png>)

### When to use

- When navigation to a page fails because the requested resource is unavailable or blocked.
- When an application route represents a standalone error state, such as `401`, `403`, `404`, or `500`.

### Best practices

- Do not use them for transient background failures that can be communicated with [inline notifications](<https://element.siemens.io/components/status-notifications/inline-notification/>) or [toast notifications](<https://element.siemens.io/components/status-notifications/toast-notification/>).
- Codes can be remapped deliberately (on server side) when necessary, for example showing a 404 page for a 403 error to avoid revealing that a restricted resource exists.

## Design

### Anatomy

![HTTP error pages anatomy](<../images/http-error-pages-anatomy.png>)

1. **Illustration**
2. **Heading**: State the problem in a short, human-readable way with the error code.
3. **Description (optional)**: Briefly explain what happened or what could have caused it.
4. **Actions (optional)**: Offer a relevant escape path or recovery action.

### Visual guidance

There are five predefined illustrations mapped to different error codes.

![HTTP error pages illustrations](<../images/http-error-pages-illustrations.png>)

| Illustration | Use for | Meaning | Mapped codes |
| --- | --- | --- | --- |
| **Document** | Request errors and unsupported requests | The request cannot be processed in its current form. | `400`, `405`, `406`, `409`, `411`<br>`412`, `413`, `414`, `415`, `417`<br>`421`, `422`, `428`, `431` |
| **Lock** | Authentication and access restrictions | The user must sign in, does not have access, or the resource is restricted. | `401`, `403`, `407`<br>`423`, `451`, `511` |
| **Magnifier** | Missing resources | The page or resource cannot be found or is no longer available. | `404`, `410` |
| **Hourglass** | Timeout and temporary availability issues | The service is busy, delayed, or temporarily unavailable. | `408`, `425`, `429`, `504` |
| **Plug** | Server and backend failures | The application or an upstream service failed unexpectedly. | `500`, `501`, `502`, `503`<br>`505`, `506`, `507`, `508`, `510` |

- Dedicated [UX writing copy](<https://element.siemens.io/fundamentals/ux-text-style-guide/error-pages/>) already exists for common error types.
- For less common errors that do not have dedicated UX writing copy, use the error code together with the official HTTP status title from the [IANA HTTP status code registry](<https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml>).

## Code

The HTTP error page examples are making use of the [info page](<https://element.siemens.io/components/pages/info-page/>) component (`si-info-page`) as the base layout.

Import `SiInfoPageComponent`, `NgOptimizedImage` for the illustration, and `SiTranslatePipe` when its alternative text uses a translation key.

```
import { NgOptimizedImage } from '@angular/common';
import { SiInfoPageComponent } from '@siemens/element-ng/info-page';
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';

@Component({
  imports: [NgOptimizedImage, SiInfoPageComponent, SiTranslatePipe],
  ...
})
```

Set the heading, description, and alternative text using the keys for the relevant HTTP error. Project the mapped illustration and suitable recovery actions into the info page.

```
<si-info-page
  titleText="SI_HTTP_ERRORS.NOT_FOUND.HEADING"
  description="SI_HTTP_ERRORS.NOT_FOUND.DESCRIPTION"
>
  <img
    class="si-info-image"
    [alt]="'SI_HTTP_ERRORS.NOT_FOUND.ALT' | translate"
    ngSrc="./assets/images/magnifier.svg"
    width="260"
    height="190"
  />
  <div class="si-info-actions">
    <button type="button" class="btn btn-secondary">Go back</button>
    <button type="button" class="btn btn-secondary">Search app</button>
  </div>
</si-info-page>
```

For Siemens-internal applications, localized headings, descriptions, and alternative texts are available through the Siemens-internal language packs. Append `.HEADING`, `.DESCRIPTION`, or `.ALT` to one of these key prefixes:

| HTTP code | Translation key prefix | Illustration |
| --- | --- | --- |
| `400` | `SI_HTTP_ERRORS.BAD_REQUEST` | [document.svg](<https://element.siemens.io/patterns/http-error-illustrations/document.svg>) |
| `401` | `SI_HTTP_ERRORS.UNAUTHORIZED` | [lock.svg](<https://element.siemens.io/patterns/http-error-illustrations/lock.svg>) |
| `404` | `SI_HTTP_ERRORS.NOT_FOUND` | [magnifier.svg](<https://element.siemens.io/patterns/http-error-illustrations/magnifier.svg>) |
| `418` | `SI_HTTP_ERRORS.TEAPOT` | [teapot.svg](<https://element.siemens.io/patterns/http-error-illustrations/teapot.svg>) |
| `500` | `SI_HTTP_ERRORS.INTERNAL_SERVER_ERROR` | [plug.svg](<https://element.siemens.io/patterns/http-error-illustrations/plug.svg>) |
| `504` | `SI_HTTP_ERRORS.GATEWAY_TIMEOUT` | [hourglass.svg](<https://element.siemens.io/patterns/http-error-illustrations/hourglass.svg>) |

### Example

Select an HTTP status code to preview the corresponding error page and illustration.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { NgOptimizedImage } from '@angular/common';
import { Component, computed, inject, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import { SiInfoPageComponent } from '@siemens/element-ng/info-page';
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';
import { LOG_EVENT } from '@siemens/live-preview';

@Component({
  selector: 'app-sample',
  imports: [
    SiInfoPageComponent,
    SiFormItemComponent,
    FormsModule,
    NgOptimizedImage,
    SiTranslatePipe
  ],
  templateUrl: './http-error-pages.html'
})
export class SampleComponent {
  protected readonly logEvent = inject(LOG_EVENT);

  protected readonly httpErrorPages = [
    {
      id: '404',
      heading: 'SI_HTTP_ERRORS.NOT_FOUND.HEADING',
      description: 'SI_HTTP_ERRORS.NOT_FOUND.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.NOT_FOUND.ALT',
        src: './assets/images/magnifier.svg'
      },
      actions: [
        {
          title: 'Search app',
          style: 'secondary',
          action: () => this.logEvent('Search app clicked')
        },
        {
          title: 'Open homepage',
          style: 'primary',
          action: () => this.logEvent('Open homepage clicked')
        }
      ]
    },
    {
      id: '504',
      heading: 'SI_HTTP_ERRORS.GATEWAY_TIMEOUT.HEADING',
      description: 'SI_HTTP_ERRORS.GATEWAY_TIMEOUT.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.GATEWAY_TIMEOUT.ALT',
        src: './assets/images/hourglass.svg'
      },
      actions: [
        {
          title: 'Go back',
          style: 'secondary',
          action: () => this.logEvent('Go back clicked')
        },
        {
          title: 'Open homepage',
          style: 'primary',
          action: () => this.logEvent('Open homepage clicked')
        }
      ]
    },
    {
      id: '401',
      heading: 'SI_HTTP_ERRORS.UNAUTHORIZED.HEADING',
      description: 'SI_HTTP_ERRORS.UNAUTHORIZED.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.UNAUTHORIZED.ALT',
        src: './assets/images/lock.svg'
      },
      actions: [
        {
          title: 'Go back',
          style: 'secondary',
          action: () => this.logEvent('Go back clicked')
        },
        {
          title: 'Login',
          style: 'primary',
          action: () => this.logEvent('Login clicked')
        }
      ]
    },
    {
      id: '500',
      heading: 'SI_HTTP_ERRORS.INTERNAL_SERVER_ERROR.HEADING',
      description: 'SI_HTTP_ERRORS.INTERNAL_SERVER_ERROR.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.INTERNAL_SERVER_ERROR.ALT',
        src: './assets/images/plug.svg'
      },
      actions: [
        {
          title: 'Go back',
          style: 'secondary',
          action: () => this.logEvent('Go back clicked')
        },
        {
          title: 'Open homepage',
          style: 'primary',
          action: () => this.logEvent('Open homepage clicked')
        }
      ]
    },
    {
      id: '400',
      heading: 'SI_HTTP_ERRORS.BAD_REQUEST.HEADING',
      description: 'SI_HTTP_ERRORS.BAD_REQUEST.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.BAD_REQUEST.ALT',
        src: './assets/images/document.svg'
      },
      actions: [
        {
          title: 'Go back',
          style: 'secondary',
          action: () => this.logEvent('Go back clicked')
        },
        {
          title: 'Open homepage',
          style: 'primary',
          action: () => this.logEvent('Open homepage clicked')
        }
      ]
    },
    {
      id: '418',
      heading: 'SI_HTTP_ERRORS.TEAPOT.HEADING',
      description: 'SI_HTTP_ERRORS.TEAPOT.DESCRIPTION',
      illustration: {
        alt: 'SI_HTTP_ERRORS.TEAPOT.ALT',
        src: './assets/images/teapot.svg'
      }
    }
  ];

  protected readonly selectedId = signal(this.httpErrorPages[0].id);
  protected readonly selectedPage = computed(() =>
    this.httpErrorPages.find(page => page.id === this.selectedId())!
  );
}
```

Template:

```html
<div class="d-flex flex-column p-8 h-100">
  <si-info-page [titleText]="selectedPage().heading" [description]="selectedPage().description">
    <img
      class="si-info-image"
      [alt]="selectedPage().illustration.alt | translate"
      [ngSrc]="selectedPage().illustration.src"
      [width]="260"
      [height]="190"
    />
    @if (selectedPage().actions; as actions) {
      <div class="si-info-actions">
        @for (action of actions; track action.title) {
          <button
            type="button"
            class="btn me-6 mb-6"
            [class.btn-primary]="action.style === 'primary'"
            [class.btn-secondary]="action.style === 'secondary'"
            (click)="action.action()"
          >
            {{ action.title }}
          </button>
        }
      </div>
    }
  </si-info-page>
  <div class="card e2e-ignore">
    <div class="card-header">Settings</div>
    <div class="card-body">
      <div class="col-sm-3">
        <si-form-item label="Choose HTTP error code">
          <select class="form-select" [(ngModel)]="selectedId">
            @for (errorPage of httpErrorPages; track errorPage.id) {
              <option [value]="errorPage.id">{{ errorPage.heading | translate }}</option>
            }
          </select>
        </si-form-item>
      </div>
    </div>
  </div>
</div>
```
