Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 주가 지수 서비스 테스트 코드 작성 #236

Merged
merged 10 commits into from
Dec 2, 2024
Prev Previous commit
Next Next commit
🔧 fix: stock index 데이터 안 들어왔을 때 예외 처리 추가
sieunie committed Dec 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8ede780f742d5bf403d80ed8fc46ee035496ff00
12 changes: 11 additions & 1 deletion BE/src/stock/index/stock-index.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { StockIndexListChartElementDto } from './dto/stock-index-list-chart.element.dto';
import { StockIndexValueElementDto } from './dto/stock-index-value-element.dto';
import {
@@ -87,6 +87,11 @@ export class StockIndexService {
queryParams,
);

if (result.rt_cd !== '0')
throw new InternalServerErrorException(
'데이터를 정상적으로 조회하지 못했습니다.',
);

return result.output.map((element) => {
return new StockIndexListChartElementDto(
element.bsop_hour,
@@ -109,6 +114,11 @@ export class StockIndexService {
queryParams,
);

if (result.rt_cd !== '0')
throw new InternalServerErrorException(
'데이터를 정상적으로 조회하지 못했습니다.',
);

const data = result.output;

return new StockIndexValueElementDto(