-
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.
added Custom Exception and some minor changes
- Loading branch information
1 parent
55b4887
commit a39f1bc
Showing
5 changed files
with
66 additions
and
9 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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/strong/speedsyncrestful/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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.strong.speedsyncrestful.Exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(SpeedSyncException.class) | ||
|
||
public ResponseEntity<?> handleSpeedException(SpeedSyncException exception) { | ||
SpeedRes response = new SpeedRes(); | ||
response.setMessage(exception.getLocalizedMessage()); | ||
response.setStatus(HttpStatus.CONFLICT.value()); | ||
response.setTimeStamp(System.currentTimeMillis()); | ||
return new ResponseEntity<>(response, HttpStatus.CONFLICT); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/strong/speedsyncrestful/Exception/SpeedRes.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.strong.speedsyncrestful.Exception; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
public class SpeedRes { | ||
private String Message; | ||
private Integer Status; | ||
private long TimeStamp; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/strong/speedsyncrestful/Exception/SpeedSyncException.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.strong.speedsyncrestful.Exception; | ||
|
||
|
||
public class SpeedSyncException extends Exception { | ||
|
||
public SpeedSyncException() { | ||
super(); | ||
} | ||
|
||
public SpeedSyncException(String Message) { | ||
super(Message); | ||
} | ||
|
||
public SpeedSyncException(String Message, Throwable throwable) { | ||
super(Message, throwable); | ||
} | ||
|
||
public SpeedSyncException(Throwable throwable) { | ||
super(throwable); | ||
} | ||
|
||
} |
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