mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-WebAPi.git
synced 2026-04-01 23:14:51 +00:00
fix: 添加错误URL异常抛出
This commit is contained in:
parent
5176183445
commit
764e9ecb1e
2 changed files with 18 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
package com.cloverta.webapi.controller;
|
||||
|
||||
import com.cloverta.webapi.restservice.Error;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class CustomErrorController implements ErrorController {
|
||||
@RequestMapping("/error")
|
||||
public Error error() {
|
||||
return new Error("ERROR", "Something went wrong... I hope it wasn't my fault.");
|
||||
}
|
||||
}
|
||||
4
src/main/java/com/cloverta/webapi/restservice/Error.java
Normal file
4
src/main/java/com/cloverta/webapi/restservice/Error.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
package com.cloverta.webapi.restservice;
|
||||
|
||||
public record Error(String status, String message) {
|
||||
}
|
||||
Loading…
Reference in a new issue