-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1035 from amvanbaren/feature/custom-error-page
Add ServerErrorController
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
server/src/main/java/org/eclipse/openvsx/web/ServerErrorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** ****************************************************************************** | ||
* Copyright (c) 2024 Precies. Software OU and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* ****************************************************************************** */ | ||
package org.eclipse.openvsx.web; | ||
|
||
import org.eclipse.openvsx.util.UrlUtil; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.web.servlet.error.ErrorController; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
@ConditionalOnProperty(value = "server.error.path", havingValue = "/server-error") | ||
public class ServerErrorController implements ErrorController { | ||
|
||
@Value("${ovsx.webui.url:}") | ||
String webuiUrl; | ||
|
||
@RequestMapping("/server-error") | ||
public String handleError() { | ||
return "redirect:" + UrlUtil.createApiUrl(webuiUrl, "error"); | ||
} | ||
} |