Update dependencies and remove gateway
* Remove Gateway module, configuration, and references * Update backend services to directly handle requests under `/api` prefix * Adjust frontend contact route to connect directly to the server * Centralize authentication logic and integrate token refresh mechanism
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package dev.rheinsw.common.controller.exception;
|
||||
|
||||
/**
|
||||
* @author Thatsaphorn Atchariyaphap
|
||||
* @since 06.07.25
|
||||
*/
|
||||
public class ApiException extends RuntimeException {
|
||||
public ApiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ApiException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package dev.rheinsw.common.controller.exception.handler;
|
||||
|
||||
import dev.rheinsw.common.controller.exception.ApiException;
|
||||
import dev.rheinsw.common.usecase.exception.UseCaseException;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Thatsaphorn Atchariyaphap
|
||||
* @since 06.07.25
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(ApiException.class)
|
||||
public ResponseEntity<ApiErrorResponse> handleBusinessException(ApiException ex) {
|
||||
return ResponseEntity.badRequest().body(
|
||||
new ApiErrorResponse(Instant.now(), ex.getMessage(), List.of(ex.getMessage()))
|
||||
);
|
||||
}
|
||||
|
||||
@ExceptionHandler(UseCaseException.class)
|
||||
public ResponseEntity<ApiErrorResponse> handleUseCaseException(UseCaseException ex) {
|
||||
return ResponseEntity.badRequest().body(
|
||||
new ApiErrorResponse(Instant.now(), ex.getMessage(), List.of(ex.getMessage()))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ApiErrorResponse> handleGeneric(Exception ex) {
|
||||
ex.printStackTrace(); // log the stack trace
|
||||
return ResponseEntity.internalServerError().body(
|
||||
new ApiErrorResponse(Instant.now(), "Ein unerwarteter Fehler ist aufgetreten", List.of(ex.getMessage()))
|
||||
);
|
||||
}
|
||||
|
||||
public record ApiErrorResponse(
|
||||
Instant timestamp,
|
||||
String message,
|
||||
List<String> errors
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.rheinsw.common.usecase.exception;
|
||||
|
||||
/**
|
||||
* @author Thatsaphorn Atchariyaphap
|
||||
* @since 06.07.25
|
||||
*/
|
||||
public class UseCaseException extends RuntimeException {
|
||||
public UseCaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UseCaseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user