-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor exception handling and remove unused dependencies
- Loading branch information
1 parent
c455ed0
commit 4a1d71f
Showing
4 changed files
with
4 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/main/java/com/ms/gatewayserver/exception/GlobalExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
src/main/java/com/ms/gatewayserver/external/identity/IIdentityFeignClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
src/main/java/com/ms/gatewayserver/external/identity/models/VerificationResult.java
This file was deleted.
Oops, something went wrong.