diff --git a/server/src/main/java/org/eclipse/openvsx/web/ServerErrorController.java b/server/src/main/java/org/eclipse/openvsx/web/ServerErrorController.java new file mode 100644 index 00000000..7968183d --- /dev/null +++ b/server/src/main/java/org/eclipse/openvsx/web/ServerErrorController.java @@ -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"); + } +}