refactor: 메일 에러 처리 개선
This commit is contained in:
parent
80b6e3644c
commit
927d13ad99
@ -7,6 +7,7 @@ import { getIronSession } from 'iron-session'
|
|||||||
import { SessionData } from '@/types/Auth'
|
import { SessionData } from '@/types/Auth'
|
||||||
import { sessionOptions } from '@/libs/session'
|
import { sessionOptions } from '@/libs/session'
|
||||||
import { cookies } from 'next/headers'
|
import { cookies } from 'next/headers'
|
||||||
|
import { ERROR_MESSAGE } from '@/hooks/useAlertMsg'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {POST} /api/qna/save 문의 저장 API
|
* @api {POST} /api/qna/save 문의 저장 API
|
||||||
@ -37,7 +38,7 @@ async function setQna(request: Request): Promise<NextResponse> {
|
|||||||
const formData = await request.formData()
|
const formData = await request.formData()
|
||||||
const mailResult = await service.sendMail(formData)
|
const mailResult = await service.sendMail(formData)
|
||||||
if (mailResult instanceof ApiError) {
|
if (mailResult instanceof ApiError) {
|
||||||
return NextResponse.json({ error: mailResult.message }, { status: mailResult.statusCode })
|
return NextResponse.json({ error: ERROR_MESSAGE.EMAIL_SEND_ERROR }, { status: HttpStatusCode.InternalServerError })
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await service.tryFunction(() =>
|
const result = await service.tryFunction(() =>
|
||||||
|
|||||||
@ -35,6 +35,9 @@ export class QnaService {
|
|||||||
if (shouldThrowResult) return response
|
if (shouldThrowResult) return response
|
||||||
return this.handleResult(response)
|
return this.handleResult(response)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (shouldThrowResult) {
|
||||||
|
return new ApiError(HttpStatusCode.InternalServerError, ERROR_MESSAGE.SERVER_ERROR)
|
||||||
|
}
|
||||||
return this.handleRouteError(error)
|
return this.handleRouteError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { useSessionStore } from '@/store/session'
|
|||||||
import { InquiryRequest } from '@/types/Inquiry'
|
import { InquiryRequest } from '@/types/Inquiry'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { CONFIRM_MESSAGE, ERROR_MESSAGE, SUCCESS_MESSAGE, useAlertMsg, WARNING_MESSAGE } from '@/hooks/useAlertMsg'
|
import { CONFIRM_MESSAGE, SUCCESS_MESSAGE, useAlertMsg, WARNING_MESSAGE } from '@/hooks/useAlertMsg'
|
||||||
import { useInquiryFilterStore } from '@/store/inquiryFilterStore'
|
import { useInquiryFilterStore } from '@/store/inquiryFilterStore'
|
||||||
|
|
||||||
export default function RegistForm() {
|
export default function RegistForm() {
|
||||||
@ -106,12 +106,10 @@ export default function RegistForm() {
|
|||||||
showConfirm(
|
showConfirm(
|
||||||
CONFIRM_MESSAGE.SAVE_INQUIRY_CONFIRM,
|
CONFIRM_MESSAGE.SAVE_INQUIRY_CONFIRM,
|
||||||
async () => {
|
async () => {
|
||||||
try {
|
const res = await saveInquiry(formData)
|
||||||
const res = await saveInquiry(formData)
|
if (!isSavingInquiry) {
|
||||||
showSuccessAlert(SUCCESS_MESSAGE.SAVE_SUCCESS)
|
showSuccessAlert(SUCCESS_MESSAGE.SAVE_SUCCESS)
|
||||||
router.push(`/inquiry/${res.qnaNo}`)
|
router.push(`/inquiry/${res.qnaNo}`)
|
||||||
} catch (error) {
|
|
||||||
showErrorAlert(ERROR_MESSAGE.SERVER_ERROR)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => null,
|
() => null,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { useInquiryFilterStore } from '@/store/inquiryFilterStore'
|
|||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { useAlertMsg } from '@/hooks/useAlertMsg'
|
import { useAlertMsg } from '@/hooks/useAlertMsg'
|
||||||
import { CommCode } from '@/types/CommCode'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 문의사항 관련 기능을 제공하는 커스텀 훅
|
* @description 문의사항 관련 기능을 제공하는 커스텀 훅
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user