Skip to content

Commit

Permalink
Task 20 : Revise CustomError and CustomResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapter1990 committed Jun 30, 2024
1 parent 9fe2432 commit fe21ac7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public enum Header {

DATABASE_ERROR("DATABASE ERROR"),

PROCESS_ERROR("PROCESS ERROR");
PROCESS_ERROR("PROCESS ERROR"),

RATE_LIMITER_EXCEEDED_ERROR("RATE LIMITER EXCEEDED ERROR");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Builder;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

import java.time.LocalDateTime;

Expand All @@ -27,11 +28,20 @@ public class CustomResponse<T> {
.build();


public static <T> CustomResponse<T> successOf(final T response) {
return CustomResponse.<T>builder()
.httpStatus(HttpStatus.OK)
public static <E> CustomResponse<E> ok(E response) {
return CustomResponse.<E>builder()
.response(response)
.isSuccess(true)
.httpStatus(HttpStatus.OK)
.build();
}

@ResponseStatus(HttpStatus.CREATED)
public static <E> CustomResponse<E> created(E response) {
return CustomResponse.<E>builder()
.response(response)
.isSuccess(true)
.httpStatus(HttpStatus.CREATED)
.build();
}

Expand Down

0 comments on commit fe21ac7

Please sign in to comment.