Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame^] | 1 | # Copyright 2016 The Chromium Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | """Page class for generating somewhat informative project-page 404s. |
| 6 | |
| 7 | This page class produces a mostly-empty project subpage, which helps |
| 8 | users find what they're looking for by providing navigational menus, |
| 9 | rather than telling them "404. That's an error. That's all we know." |
| 10 | which is maddeningly not helpful when we already have a project pb |
| 11 | loaded. |
| 12 | """ |
| 13 | from __future__ import print_function |
| 14 | from __future__ import division |
| 15 | from __future__ import absolute_import |
| 16 | |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 17 | from six.moves import http_client |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 18 | from framework import exceptions |
| 19 | from framework import servlet |
| 20 | |
| 21 | |
| 22 | class ErrorPage(servlet.Servlet): |
| 23 | """Page class for generating somewhat informative project-page 404s. |
| 24 | |
| 25 | This page class produces a mostly-empty project subpage, which helps |
| 26 | users find what they're looking for by providing navigational menus, |
| 27 | rather than telling them "404. That's an error. That's all we know." |
| 28 | which is maddeningly not helpful when we already have a project pb |
| 29 | loaded. |
| 30 | """ |
| 31 | |
| 32 | _PAGE_TEMPLATE = 'sitewide/project-404-page.ezt' |
| 33 | |
| 34 | def GatherPageData(self, mr): |
| 35 | """Build up a dictionary of data values to use when rendering the page.""" |
| 36 | if not mr.project_name: |
| 37 | raise exceptions.InputException('No project specified') |
| 38 | return { |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 39 | 'http_response_code': http_client.NOT_FOUND, |
| 40 | } |
| 41 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame^] | 42 | def Get404Page(self, **kwargs): |
| 43 | return self.handler(**kwargs) |