Skip to content

Commit c123517

Browse files
authored
Merge pull request #1035 from amvanbaren/feature/custom-error-page
Add ServerErrorController
2 parents 02f393f + 54cfb9a commit c123517

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/** ******************************************************************************
2+
* Copyright (c) 2024 Precies. Software OU and others
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
* ****************************************************************************** */
10+
package org.eclipse.openvsx.web;
11+
12+
import org.eclipse.openvsx.util.UrlUtil;
13+
import org.springframework.beans.factory.annotation.Value;
14+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
15+
import org.springframework.boot.web.servlet.error.ErrorController;
16+
import org.springframework.stereotype.Controller;
17+
import org.springframework.web.bind.annotation.RequestMapping;
18+
19+
@Controller
20+
@ConditionalOnProperty(value = "server.error.path", havingValue = "/server-error")
21+
public class ServerErrorController implements ErrorController {
22+
23+
@Value("${ovsx.webui.url:}")
24+
String webuiUrl;
25+
26+
@RequestMapping("/server-error")
27+
public String handleError() {
28+
return "redirect:" + UrlUtil.createApiUrl(webuiUrl, "error");
29+
}
30+
}

0 commit comments

Comments
 (0)