new exception

This commit is contained in:
Niktia 2025-02-19 16:10:46 +03:00
parent 9d45d45d35
commit 83d89f4921
3 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,9 @@
package com.example.nto.dto;
import lombok.Data;
@Data
public class CodeDto {
private Long value;
}

View File

@ -0,0 +1,7 @@
package com.example.nto.exception;
public class CodeNotFoundException extends RuntimeException {
public CodeNotFoundException(String message) {
super(message);
}
}

View File

@ -9,6 +9,11 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(CodeNotFoundException.class)
public ResponseEntity<String> handleEntersNotFoundException(CodeNotFoundException e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
}
@ExceptionHandler(EntersNotFoundException.class)
public ResponseEntity<String> handleEntersNotFoundException(EntersNotFoundException e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
@ -73,5 +78,4 @@ public class GlobalExceptionHandler {
public ResponseEntity<String> handleAuthorityNotFoundException(AuthorityNotFoundException e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
}
}