Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.RDS.skilltree.exceptions;

import com.RDS.skilltree.utils.Constants.ExceptionMessages;
import com.RDS.skilltree.utils.GenericResponse;
import jakarta.validation.ConstraintViolationException;
import java.util.List;
Expand Down Expand Up @@ -27,10 +28,7 @@ public ResponseEntity<GenericResponse<Object>> handleNoEntityException(NoEntityE
@ExceptionHandler({AuthenticationException.class, InsufficientAuthenticationException.class})
public ResponseEntity<GenericResponse<Object>> handleInvalidBearerTokenException(Exception ex) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.body(
new GenericResponse<>(
null,
"The access token provided is expired, revoked, malformed, or invalid for other reasons."));
.body(new GenericResponse<>(ExceptionMessages.INVALID_ACCESS_TOKEN));
}

@ExceptionHandler({AccessDeniedException.class})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.RDS.skilltree.dtos.RdsGetUserDetailsResDto;
import com.RDS.skilltree.exceptions.UserNotFoundException;
import com.RDS.skilltree.utils.Constants.ExceptionMessages;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -26,7 +27,7 @@ public RdsGetUserDetailsResDto getUserDetails(String id) {
return restTemplate.getForObject(url, RdsGetUserDetailsResDto.class);
} catch (RestClientException error) {
log.error("Error calling url {}, error: {}", url, error.getMessage());
throw new UserNotFoundException("Error getting user details");
throw new UserNotFoundException(ExceptionMessages.USER_NOT_FOUND);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ public static final class ExceptionMessages {
public static final String SKILL_NOT_FOUND = "Skill does not exist";
public static final String ENDORSEMENT_ALREADY_EXISTS = "Endorsement already exists";
public static final String ENDORSEMENT_NOT_FOUND = "Endorsement not found";
public static final String ENDORSEMENT_MESSAGE_EMPTY = "Endorsement message cannot be empty";
public static final String USER_NOT_FOUND = "Error getting user details";
public static final String UNAUTHORIZED_ENDORSEMENT_UPDATE =
"Not authorized to update this endorsement";
public static final String INVALID_ACCESS_TOKEN =
"The access token provided is expired, revoked, malformed, or invalid for other reasons.";
public static final String ACCESS_DENIED = "Access Denied";
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.RDS.skilltree.viewmodels;

import com.RDS.skilltree.utils.Constants.ExceptionMessages;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class UpdateEndorsementViewModel {
@NotNull(message = "Message cannot be empty")
@NotNull(message = ExceptionMessages.ENDORSEMENT_MESSAGE_EMPTY)
private String message;
}
2 changes: 1 addition & 1 deletion skill-tree/src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cookieName=rds-session-v2-development
cookieName=rds-session-v2
test.db.mysql-image=mysql:8.1.0
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migrations
Expand Down
Loading