Skip to content

Commit

Permalink
♻️ refactor(notification): use custom ErrorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
siyeonSon committed Apr 8, 2024
1 parent e54721a commit f57aa94
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.depromeet.domains.notification.service;

import static com.depromeet.common.error.code.TokenErrorCode.TOKEN_NOT_FOUND;

import com.depromeet.common.error.exceptions.NotFoundException;
import com.depromeet.domains.notification.dto.request.AllPushRequestDto;
import com.depromeet.domains.notification.dto.request.PushRequestDto;
import com.depromeet.domains.notification.dto.request.TopicPushRequestDto;
Expand Down Expand Up @@ -28,7 +31,7 @@ public void save(PushRequestDto pushRequestDto) {

for (Long userId : pushRequestDto.getUserIds()) {
var userDevice = userDeviceRepository.findByUserId(userId)
.orElseThrow(() -> new RuntimeException("Token not found for userId: " + userId));
.orElseThrow(() -> new NotFoundException(TOKEN_NOT_FOUND));
if (userDevice.isAlertOn()) {
var notificationAction = NotificationAction.builder()
.path(pushRequestDto.getPath())
Expand Down

0 comments on commit f57aa94

Please sign in to comment.