api: Error stuff
parent
c5c8797ba2
commit
a2fc1b44e5
19
pom.xml
19
pom.xml
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -30,34 +31,42 @@
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency> -->
|
</dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||||
</dependency> -->
|
</dependency> -->
|
||||||
|
|
||||||
<!-- <dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||||
</dependency> -->
|
</dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
@ -65,6 +74,13 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>4.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
|
@ -77,6 +93,7 @@
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
|
|
@ -1,58 +1,23 @@
|
||||||
package com.maradona.backend.controllers.page;
|
package com.maradona.backend.controllers.page;
|
||||||
|
|
||||||
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
import javax.servlet.http.HttpServletRequest;
|
||||||
* Controller for routing to the error pages.
|
|
||||||
*
|
|
||||||
* List of endpoints:
|
|
||||||
* - GET /error/400
|
|
||||||
* - GET /error/404
|
|
||||||
* - GET /error/500
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
|
public class ErrorPage implements ErrorController {
|
||||||
|
|
||||||
@RequestMapping("/error")
|
@RequestMapping("/error")
|
||||||
public class ErrorPage {
|
public String handleError(HttpServletRequest request, Model model) {
|
||||||
/**
|
Object status = request.getAttribute("javax.servlet.error.status_code");
|
||||||
* Error page for 400 Bad Request.
|
Object message = request.getAttribute("javax.servlet.error.message");
|
||||||
*
|
|
||||||
* This page is displayed when the request is malformed and the server cannot
|
|
||||||
* process it.
|
|
||||||
*
|
|
||||||
* @return The 400 error page template.
|
|
||||||
*/
|
|
||||||
@GetMapping("/400")
|
|
||||||
public String error400() {
|
|
||||||
return "pages/error/400";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
model.addAttribute("status", status);
|
||||||
* Error page for 404 Not Found.
|
model.addAttribute("message", message);
|
||||||
*
|
|
||||||
* This page is displayed when the requested resource could not be found on the
|
|
||||||
* server. This can be due to a wrong URL or a deleted resource. The user should
|
|
||||||
* be informed that the resource is not available.
|
|
||||||
*
|
|
||||||
* @return The 404 error page template.
|
|
||||||
*/
|
|
||||||
@GetMapping("/404")
|
|
||||||
public String error404() {
|
|
||||||
return "pages/error/404";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return "pages/core/error";
|
||||||
* Error page for 500 Internal Server Error.
|
|
||||||
*
|
|
||||||
* This page is displayed when the server encountered an unexpected condition
|
|
||||||
* that prevented it from fulfilling the request. The user should be informed
|
|
||||||
* that the server is experiencing problems and the request cannot be processed.
|
|
||||||
*
|
|
||||||
* @return The 500 error page template.
|
|
||||||
*/
|
|
||||||
@GetMapping("/500")
|
|
||||||
public String error500() {
|
|
||||||
return "pages/error/500";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,14 +45,4 @@ public class Page {
|
||||||
public String datenschutz() {
|
public String datenschutz() {
|
||||||
return "pages/core/datenschutz";
|
return "pages/core/datenschutz";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the notes page.
|
|
||||||
*
|
|
||||||
* @return The notes page template.
|
|
||||||
*/
|
|
||||||
@GetMapping("/notes")
|
|
||||||
public String notes() {
|
|
||||||
return "pages/core/notes";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,3 +43,8 @@ logging:
|
||||||
http:
|
http:
|
||||||
converter:
|
converter:
|
||||||
json: DEBUG
|
json: DEBUG
|
||||||
|
server:
|
||||||
|
error:
|
||||||
|
path: /error
|
||||||
|
whitelabel:
|
||||||
|
enabled: false
|
||||||
|
|
Loading…
Reference in New Issue