Skip to content

Commit

Permalink
[CHORE] Sentry 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Mar 23, 2024
1 parent 75e3be1 commit e43ec62
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.smeem.api.common.dto.FailureResponse;
import com.smeem.common.exception.*;
import com.smeem.external.discord.DiscordAlarmSender;
import io.sentry.Sentry;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand All @@ -20,61 +21,72 @@ public class ErrorHandler {

@ExceptionHandler(TrainingTimeException.class)
public ResponseEntity<FailureResponse> trainingTimeException(TrainingTimeException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(TokenException.class)
public ResponseEntity<FailureResponse> tokenException(TokenException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(BadgeException.class)
public ResponseEntity<FailureResponse> badgeException(BadgeException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(DiaryException.class)
public ResponseEntity<FailureResponse> diaryException(DiaryException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(MemberException.class)
public ResponseEntity<FailureResponse> memberException(MemberException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(GoalException.class)
public ResponseEntity<FailureResponse> goalException(GoalException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(TopicException.class)
public ResponseEntity<FailureResponse> topicException(TopicException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(AppleException.class)
public ResponseEntity<FailureResponse> appleException(AppleException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(FcmException.class)
public ResponseEntity<FailureResponse> fcmException(FcmException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(AuthException.class)
public ResponseEntity<FailureResponse> authException(AuthException exception) {
Sentry.captureException(exception);
return ApiResponseUtil.failure(exception.getFailureCode());
}

@ExceptionHandler(RuntimeException.class)
public ResponseEntity<FailureResponse> baseException(RuntimeException exception) {
sendDiscordAlarm(exception);
Sentry.captureException(exception);
return ApiResponseUtil.failure(SERVER_ERROR);
}

private void sendDiscordAlarm(RuntimeException exception) {
discordAlarmSender.send(exception.getMessage(), ERROR);
discordAlarmSender.send(exception.getMessage(), ERROR);
}
}
}
8 changes: 7 additions & 1 deletion smeem-api/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ smeem:
discord:
webhook:
error-url: ${DISCORD.WEBHOOK_ERROR_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}

sentry:
dsn: ${SENTRY.DSN}
environment: dev
enable-tracing: true
exception-resolver-order: -2147483647
8 changes: 7 additions & 1 deletion smeem-api/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ smeem:
discord:
webhook:
error-url: ${DISCORD.WEBHOOK_ERROR_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}

sentry:
dsn: ${SENTRY.DSN}
environment: prod
enable-tracing: true
exception-resolver-order: -2147483647

0 comments on commit e43ec62

Please sign in to comment.