-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hw add global exception handler #7
Conversation
validation annotations added to CreateBookRequestDto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
private String author; | ||
@NotNull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NotNull | |
@NotBlank |
.map(this::getErrorMessage) | ||
.toList(); | ||
body.put("error", errors); | ||
return new ResponseEntity<>(body, headers, status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new ResponseEntity<>(body, headers, status); | |
return new ResponseEntity<>(body, headers, HttpStatus.BAD_REQUEST); |
@Constraint(validatedBy = UniqueValidation.class) | ||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Unique { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove redundant validatot
you have unique constraint in Book entity
If you would like to check isbn, it's better to use regexp pattern
pattern format isbn added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
@@ -6,4 +6,6 @@ | |||
|
|||
public interface BookRepository extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> { | |||
|
|||
boolean existsByIsbn(String isbn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
|
||
@ControllerAdvice | ||
public class CustomGlobalExceptionHandler extends ResponseEntityExceptionHandler { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.