Skip to content

Commit

Permalink
fix: update consumer options (#236)
Browse files Browse the repository at this point in the history
* feat: add getter in constants

* feat: update PaintCreatedEvent by adding missing fields

* feat: add mention record

* fix: add trust-package config

* refactor : exception integration

* refactor : exception response builder access identifier

* refactor : remove gateway exceptiontype

* feat: add gRPC paint response interface

* feat: gRPC version change 1.60 -> 1.58

* feat: add baseException

* fix: update event consumer config

* fix: config objectMapper by options

* fix: config objectMapper by options

* fix: config objectMapper by options
  • Loading branch information
210-reverof authored Feb 15, 2024
1 parent ed0f23a commit 7c9be19
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/common-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext {
protobufVersion = '3.14.0'
protobufPluginVersion = '0.9.4'
grpcVersion = '1.60.0'
grpcVersion = '1.58.0'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public ConsumerFactory<String, EaselEvent> consumerFactory() {
config.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
config.put(JsonDeserializer.TRUSTED_PACKAGES, "org.palette");
return new DefaultKafkaConsumerFactory<>(config, new StringDeserializer(),
new JsonDeserializer<>(EaselEvent.class));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.palette.exception;

import lombok.AccessLevel;
import lombok.Builder;

@Builder(access = AccessLevel.PROTECTED)
@Builder
public record ExceptionResponse(
String code,
String message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,265 @@ public enum ExceptionType {
HttpStatus.INTERNAL_SERVER_ERROR
),

// 400
USER_400_000001(
"USER_400_000001",
"INCORRECT_PARAMETER",
"요청 파라미터가 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

USER_400_000002(
"USER_400_000002",
"INCORRECT_EMAIL_PASSWORD",
"이메일 혹은 비밀번호가 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

// 401
USER_401_000001(
"USER_401_000001",
"MISSED AUTHENTICATION",
"해당 요청은 인증이 필요합니다.",
HttpStatus.UNAUTHORIZED
),

// 403
USER_403_000001(
"USER_403_000001",
"NOT ALLOWED PERMISSION",
"해당 요청에 대한 권한이 없습니다.",
HttpStatus.FORBIDDEN
),

// 404
USER_404_000001(
"USER_404_000001",
"NOT FOUNDED",
"해당 리소스가 존재하지 않습니다.",
HttpStatus.NOT_FOUND
),

// 405
USER_405_000001(
"USER_403_000005",
"NOT ALLOWED METHOD",
"올바르지 않은 요청 메서드입니다.",
HttpStatus.METHOD_NOT_ALLOWED
),

// 409
USER_409_000001(
"USER_409_000001",
"DUPLICATED",
"중복된 리소스가 있습니다.",
HttpStatus.CONFLICT
),

// 500
USER_500_000001(
"AUTH_500_000001",
"INTERNAL SERVER ERROR",
"서버 간 통신 중 예기치 못한 오류가 발생했습니다.",
HttpStatus.INTERNAL_SERVER_ERROR
),

// 400
AUTH_400_000001(
"AUTH_400_000001",
"INCORRECT_PARAMETER",
"요청 파라미터가 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

AUTH_400_000002(
"AUTH_400_000002",
"BROKEN_TOKEN",
"요청 토큰이 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

AUTH_400_000003(
"AUTH_400_000003",
"BROKEN_ATTEMPT",
"인증번호 입력 횟수를 초과했습니다.",
HttpStatus.BAD_REQUEST
),

AUTH_400_000004(
"AUTH_400_000002",
"BROKEN_PAYLOAD",
"인증번호가 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

// 401
AUTH_401_000001(
"AUTH_401_000001",
"MISSED AUTHENTICATION",
"해당 요청은 인증이 필요합니다.",
HttpStatus.UNAUTHORIZED
),

// 403
AUTH_403_000001(
"AUTH_403_000001",
"NOT ALLOWED PERMISSION",
"해당 요청에 대한 권한이 없습니다.",
HttpStatus.FORBIDDEN
),

AUTH_403_000002(
"AUTH_403_000002",
"EXPIRED_PAYLOAD",
"요청한 인증번호가 만료되었습니다.",
HttpStatus.FORBIDDEN
),

AUTH_403_000003(
"AUTH_403_000003",
"EXPIRED_PAYLOAD",
"토큰이 만료되었습니다. 다시 로그인해주세요",
HttpStatus.FORBIDDEN
),

// 404
AUTH_404_000001(
"AUTH_404_000001",
"NOT FOUNDED",
"해당 리소스가 존재하지 않습니다.",
HttpStatus.NOT_FOUND
),

// 405
AUTH_405_000001(
"AUTH_403_000005",
"NOT ALLOWED METHOD",
"올바르지 않은 요청 메서드입니다.",
HttpStatus.METHOD_NOT_ALLOWED
),

// 409
AUTH_409_000001(
"AUTH_409_000001",
"DUPLICATED",
"중복된 리소스가 있습니다.",
HttpStatus.CONFLICT
),

// 500
AUTH_500_000001(
"AUTH_500_000001",
"INTERNAL SERVER ERROR",
"서버 간 통신 중 예기치 못한 오류가 발생했습니다.",
HttpStatus.INTERNAL_SERVER_ERROR
),

// 400
NOTIFICATION_400_000001(
"NOTIFICATION_400_000001",
"INCORRECT_PARAMETER",
"요청 파라미터가 올바르지 않습니다.",
HttpStatus.BAD_REQUEST
),

// 401
NOTIFICATION_401_000001(
"NOTIFICATION_401_000001",
"MISSED AUTHENTICATION",
"해당 요청은 인증이 필요합니다.",
HttpStatus.UNAUTHORIZED
),

// 403
NOTIFICATION_403_000001(
"NOTIFICATION_403_000001",
"NOT ALLOWED PERMISSION",
"해당 요청에 대한 권한이 없습니다.",
HttpStatus.FORBIDDEN
),

// 404
NOTIFICATION_404_000001(
"NOTIFICATION_404_000001",
"NOT FOUNDED",
"해당 리소스가 존재하지 않습니다.",
HttpStatus.NOT_FOUND
),

// 405
NOTIFICATION_405_000001(
"NOTIFICATION_403_000005",
"NOT ALLOWED METHOD",
"올바르지 않은 요청 메서드입니다.",
HttpStatus.METHOD_NOT_ALLOWED
),

// 409
NOTIFICATION_409_000001(
"NOTIFICATION_409_000001",
"DUPLICATED",
"중복된 리소스가 있습니다.",
HttpStatus.CONFLICT
),

// 500
NOTIFICATION_500_000001(
"AUTH_500_000001",
"INTERNAL SERVER ERROR",
"서버 간 통신 중 예기치 못한 오류가 발생했습니다.",
HttpStatus.INTERNAL_SERVER_ERROR
),

NOTIFICATION_500_000002(
"AUTH_500_000002",
"INTERNAL SERVER ERROR",
"푸쉬 알림 전송 중 예기치 못한 오류가 발생했습니다.",
HttpStatus.INTERNAL_SERVER_ERROR
),

SOCIAL_400_000001(
"SOCIAL_400_000001",
"NOT_FOUND_USER",
"존재하지 않는 사용자입니다",
HttpStatus.BAD_REQUEST
),

SOCIAL_400_000002(
"SOCIAL_400_000002",
"NOT_FOUND_PAINT",
"존재하지 않는 Paint입니다",
HttpStatus.BAD_REQUEST
),

SOCIAL_400_000003(
"SOCIAL_400_000003",
"DUPLICATE_USER",
"이미 존재하는 사용자입니다.",
HttpStatus.BAD_REQUEST
),

SOCIAL_400_000004(
"SOCIAL_400_000004",
"DUPLICATE_REPAINT",
"이미 재게시 있는 게시글 입니다",
HttpStatus.BAD_REQUEST
),

SOCIAL_400_000005(
"SOCIAL_400_000005",
"DUPLICATE_LIKE",
"이미 좋아요 있는 게시글 입니다",
HttpStatus.BAD_REQUEST
),

SOCIAL_400_000006(
"SOCIAL_400_000006",
"DUPLICATE_MARK",
"이미 보관 있는 게시글 입니다",
HttpStatus.BAD_REQUEST
);

;

private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
@ControllerAdvice
public class GlobalExceptionHandler {

private static void logException(ExceptionResponse exceptionResponse) {
log.error(
"code : {}, message : {}, description : {}",
exceptionResponse.code(),
exceptionResponse.description(),
exceptionResponse.message()
);
}

@ExceptionHandler(value = {
MethodArgumentNotValidException.class,
MethodArgumentTypeMismatchException.class,
Expand Down Expand Up @@ -66,10 +57,23 @@ public ResponseEntity<ExceptionResponse> handleException(Exception e) {
.description(e.getLocalizedMessage())
.build();

logException(exceptionResponse);
logInternalException(e);

return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(exceptionResponse);
}

private static void logException(ExceptionResponse exceptionResponse) {
log.error(
"code : {}, message : {}, description : {}",
exceptionResponse.code(),
exceptionResponse.description(),
exceptionResponse.message()
);
}

private static void logInternalException(Exception e) {
log.error(e.getLocalizedMessage());
}
}
Loading

0 comments on commit 7c9be19

Please sign in to comment.