aboutsummaryrefslogtreecommitdiffstats
path: root/client/js/app/src/app/components/layout/error.jsx
blob: 290c201f7384e02e71ce1aa225c0249d2cf3c498 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
import React from 'react';
import { Center } from '@mantine/core';

// TODO: make a better page

function getMessage(code, location) {
  const statusCode =
    parseInt(code || new URLSearchParams(location?.search).get('code')) || 404;

  switch (statusCode) {
    case 403:
      return 'Sorry, you are not authorized to view this page.';
    case 404:
      return 'Sorry, the page you were looking for does not exist.';
    case 500:
      return 'Oops... something went wrong.';
    default:
      return 'Unknown error - really, I have no idea what is going on here.';
  }
}

export function Error({ code, location }) {
  const message = getMessage(code, location);
  return <Center sx={{ minHeight: '89px' }}>{message}</Center>;
}