Skip to content

Commit

Permalink
Refactor exception handling and remove unused dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosarapura97 committed Nov 20, 2024
1 parent c455ed0 commit 4a1d71f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
15 changes: 0 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.ms.gatewayserver.exception;

import com.ms.gatewayserver.util.ErrorDetails;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.server.ServerWebExchange;

import java.util.Date;

@ControllerAdvice
public class GlobalExceptionHandler {

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDetails> globalExceptionHandler(Exception ex, ServerWebExchange exchange) {
@ExceptionHandler(ResponseStatusException.class)
public ResponseEntity<ErrorDetails> responseStatusExceptionHandler(ResponseStatusException ex, ServerWebExchange exchange) {
ErrorDetails errorDetails = new ErrorDetails(
new Date(),
ex.getMessage(),
exchange.getRequest().getPath().value()
);
return new ResponseEntity<>(errorDetails, HttpStatus.UNAUTHORIZED);
return new ResponseEntity<>(errorDetails, ex.getStatusCode());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.ms.gatewayserver.external.identity;

import com.ms.gatewayserver.external.identity.models.TokenRequest;
import com.ms.gatewayserver.external.identity.models.VerificationResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down

This file was deleted.

0 comments on commit 4a1d71f

Please sign in to comment.