forked from codesquad-members-2021/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
192 additions
and
35 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
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
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
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
9 changes: 9 additions & 0 deletions
9
BE/src/main/java/com/codesquad/issuetracker/exception/BadRequestException.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,9 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class BadRequestException extends HttpException { | ||
public BadRequestException(String message) { | ||
super(HttpStatus.BAD_REQUEST, message); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
BE/src/main/java/com/codesquad/issuetracker/exception/BadTokenRequestException.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,9 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class BadTokenRequestException extends HttpException { | ||
public BadTokenRequestException(String message) { | ||
super(HttpStatus.BAD_REQUEST, message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
BE/src/main/java/com/codesquad/issuetracker/exception/CommentNotFoundException.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,7 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
public class CommentNotFoundException extends NotFoundException { | ||
public CommentNotFoundException() { | ||
super("comment가 존재하지 않습니다."); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
BE/src/main/java/com/codesquad/issuetracker/exception/HttpException.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.codesquad.issuetracker.exception; | ||
|
||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
public class HttpException extends RuntimeException{ | ||
|
||
private final HttpStatus httpStatus; | ||
|
||
public HttpException(HttpStatus httpStatus, String message) { | ||
super(message); | ||
this.httpStatus = httpStatus; | ||
} | ||
|
||
public HttpException(HttpStatus httpStatus, String message, Throwable cause) { | ||
super(message, cause); | ||
this.httpStatus = httpStatus; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
BE/src/main/java/com/codesquad/issuetracker/exception/HttpExceptionHandler.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,26 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import com.codesquad.issuetracker.exception.dto.HttpExceptionResponse; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class HttpExceptionHandler { | ||
|
||
@ExceptionHandler(HttpException.class) | ||
public ResponseEntity<HttpExceptionResponse> handle(HttpException httpException) { | ||
return new ResponseEntity<HttpExceptionResponse>( | ||
HttpExceptionResponse.of(httpException.getMessage()), | ||
httpException.getHttpStatus() | ||
); | ||
} | ||
|
||
@ExceptionHandler(IllegalArgumentException.class) | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public HttpExceptionResponse handleIllegalArgumentException(IllegalArgumentException illegalArgumentException){ | ||
return HttpExceptionResponse.of(illegalArgumentException.getMessage()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
BE/src/main/java/com/codesquad/issuetracker/exception/IssueNotFoundException.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,7 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
public class IssueNotFoundException extends NotFoundException { | ||
public IssueNotFoundException() { | ||
super("이슈가 존재하지 않습니다."); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
BE/src/main/java/com/codesquad/issuetracker/exception/LabelNotFoundException.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,7 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
public class LabelNotFoundException extends NotFoundException { | ||
public LabelNotFoundException() { | ||
super("라벨이 존재하지 않습니다."); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
BE/src/main/java/com/codesquad/issuetracker/exception/MilestoneNotFoundException.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,7 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
public class MilestoneNotFoundException extends NotFoundException { | ||
public MilestoneNotFoundException() { | ||
super("마일스톤이 존재하지 않습니다."); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
BE/src/main/java/com/codesquad/issuetracker/exception/NotFoundException.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,9 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class NotFoundException extends HttpException{ | ||
public NotFoundException(String message) { | ||
super(HttpStatus.NOT_FOUND, message); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
BE/src/main/java/com/codesquad/issuetracker/exception/S3UploadFailException.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,9 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class S3UploadFailException extends HttpException { | ||
public S3UploadFailException(String message, Throwable cause) { | ||
super(HttpStatus.INTERNAL_SERVER_ERROR, message, cause); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
BE/src/main/java/com/codesquad/issuetracker/exception/UnauthorizedException.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,9 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class UnauthorizedException extends HttpException { | ||
public UnauthorizedException(String message) { | ||
super(HttpStatus.UNAUTHORIZED, message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
BE/src/main/java/com/codesquad/issuetracker/exception/UserNotFoundException.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,7 @@ | ||
package com.codesquad.issuetracker.exception; | ||
|
||
public class UserNotFoundException extends NotFoundException { | ||
public UserNotFoundException() { | ||
super("유저가 존재하지 않습니다."); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
BE/src/main/java/com/codesquad/issuetracker/exception/dto/HttpExceptionResponse.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,13 @@ | ||
package com.codesquad.issuetracker.exception.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class HttpExceptionResponse { | ||
private final String message; | ||
|
||
public static HttpExceptionResponse of(String message) { | ||
return new HttpExceptionResponse(message); | ||
} | ||
} |
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
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
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
Oops, something went wrong.