Skip to content

Commit

Permalink
Fix(#171): 오류 정보 log.info() 출력하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mingeun0507 committed May 25, 2023
1 parent dbf4921 commit 7f72a36
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import com._8attery.seesaw.exception.BaseException;
import com._8attery.seesaw.exception.BaseResponseStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
Expand Down Expand Up @@ -53,6 +55,7 @@ public SignupResponseDto userSignup(Boolean agreeMarketing, String email, String

return res;
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(BaseResponseStatus.DATABASE_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
import com._8attery.seesaw.dto.api.response.*;
import com._8attery.seesaw.exception.BaseException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR;

@Slf4j
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
Expand All @@ -31,6 +35,7 @@ public Integer setUserActivityGoal(Long userId, Integer req) throws BaseExceptio
return batteryRepository.findUserActivityGoal(userId);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -45,6 +50,7 @@ public Integer setUserSleepGoal(Long userId, Integer req) throws BaseException {
return batteryRepository.findUserSleepGoal(userId);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -59,6 +65,7 @@ public Integer setUserCurActivity(Long userId, Integer req) throws BaseException
return batteryRepository.findUserCurActivity(userId);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -97,6 +104,7 @@ public Integer setUserCurSleep(Long userId, Integer req) throws BaseException {
return batteryRepository.findUserCurSleep(userId);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -112,6 +120,7 @@ public List<BatteryPercentResponseDto> getUserBatteryHistory(Long userId) throws
return batteryRepository.findUserBatteryHistory(userId, startDate, endDate);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -155,6 +164,7 @@ public List<BatteryVariationResponseDto> getUserBatteryData(Long userId) throws
return combinedData;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -221,6 +231,7 @@ public List<ActivityResponseDto> getUserActivity(Long userId, Integer year, Inte
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -299,6 +310,7 @@ public List<SleepResponseDto> getUserSleep(Long userId, Integer year, Integer mo
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -334,6 +346,7 @@ public BatteryResponseDto getUserBattery(Long userId) throws BaseException {
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import com._8attery.seesaw.dto.api.response.ChargeResponseDto;
import com._8attery.seesaw.exception.BaseException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Optional;

import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR;

@Slf4j
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
Expand Down Expand Up @@ -49,6 +50,7 @@ public ChargeResponseDto setUserCharge(Long userId, Long valueId, String chargeN
return chargeResponseDto.orElse(new ChargeResponseDto(0L, null, null));

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -60,6 +62,7 @@ public ChargeResponseDto getUserCharge(Long userId) throws BaseException {

return chargeRepository.findTodayCharge(userId);
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ProjectResponseDto addUserProject(Long userId, Long valueId, String proje
// return projectResponseDto.orElse(new ProjectResponseDto(0L, null, null, null, null, null, false));
//
// } catch (Exception exception) {
// exception.printStackTrace();
// log.info(exception.getMessage());exception.printStackTrace();
// throw new BaseException(DATABASE_ERROR);
// }

Expand Down Expand Up @@ -139,6 +139,7 @@ public ProjectResponseDto updateUserProject(Long projectId, Long userId, Long va
return projectResponseDto.orElse(new ProjectResponseDto(0L, null, null, null, null, null, false));

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -151,6 +152,7 @@ public Long retrieveUserId(Long projectId) throws BaseException {
throw new BaseException(POSTS_EMPTY_POST_ID);
return userId;
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -164,7 +166,7 @@ public void deleteUserProject(Long projectId) throws BaseException {
// if (result == 0)
// throw new BaseException(DELETE_FAIL_POST);
// } catch (Exception exception) {
// exception.printStackTrace();
// log.info(exception.getMessage());exception.printStackTrace();
// throw new BaseException(DATABASE_ERROR);
// }
Project retrievedProject = serviceUtils.retrieveProjectById(projectId);
Expand All @@ -176,6 +178,7 @@ public List<ProjectCardResponseDto> getProgressProjectList(Long userId) throws B
List<ProjectCardResponseDto> list = projectRepository.findProgressProjectList(userId);
return list;
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -186,6 +189,7 @@ public List<ProjectCardResponseDto> getCompleteProjectList(Long userId) throws B
List<ProjectCardResponseDto> list = projectRepository.findCompleteProjectList(userId);
return list;
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -200,6 +204,7 @@ public ProjectCountResponseDto getUserProjectCount(Long userId) throws BaseExcep
ProjectCountResponseDto res = new ProjectCountResponseDto(progressCount, completeCount);
return res;
} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void updateNickname(Long userId, NicknameRequestDto nicknameRequestDto) t
userRepository.updateUserNickname(userId, nicknameRequestDto.getNickName());

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -52,6 +53,7 @@ public String getUserNickname(Long userId) throws BaseException {
return userRepository.findUserNickname(userId);

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand All @@ -78,6 +80,7 @@ public UserHistoryResponseDto getUserHistory(Long userId) throws BaseException {
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import com._8attery.seesaw.domain.project.Project;
import com._8attery.seesaw.domain.value.ValueRepository;
import com._8attery.seesaw.dto.api.response.UserHistoryResponseDto;
import com._8attery.seesaw.dto.api.response.ValueInfoResponseDto;
import com._8attery.seesaw.dto.api.response.ValueResponseDto;
import com._8attery.seesaw.dto.api.response.ValueYearResponseDto;
import com._8attery.seesaw.exception.BaseException;
import com._8attery.seesaw.exception.BaseResponseStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -19,8 +19,8 @@
import java.util.List;

import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR;
import static java.time.temporal.ChronoUnit.DAYS;

@Slf4j
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
Expand Down Expand Up @@ -103,6 +103,7 @@ public ValueInfoResponseDto getUserValueInfo(Long userId, Long valueId) throws B
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down Expand Up @@ -142,6 +143,7 @@ public ValueYearResponseDto getUserValueYear(Long userId) throws BaseException {
return res;

} catch (Exception exception) {
log.info(exception.getMessage());
exception.printStackTrace();
throw new BaseException(DATABASE_ERROR);
}
Expand Down

0 comments on commit 7f72a36

Please sign in to comment.