From 2f6a811d35ac75acd8c000778b9270a9f4409d9e Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期二, 05 九月 2023 14:06:02 +0800 Subject: [PATCH] Fixed: closeAppointment method Bad use of null-like value --- PAMapp/shared/services/appointment.service.ts | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts index 2f13c2b..fa2e862 100644 --- a/PAMapp/shared/services/appointment.service.ts +++ b/PAMapp/shared/services/appointment.service.ts @@ -57,10 +57,11 @@ async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> { try { const response = await http.post('/appointment/memo/create', memoInfo); - if (response !== null) { - return response.data; - } else { + // 撘望�� test2: ���� !response + if (!response) { throw new Error('http.post returned null-like value.'); + } else { + return response.data; } } catch (error) { // �隞亙甇方���隤斗����身�� @@ -104,13 +105,13 @@ async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) { try { const response = await http.post(`/appointment/close`, appointmentInfo); - if (response !== null) { - return response.data; + if (!response) { + throw new Error('http.post returned a null-like value.'); } else { - throw new Error('http.post returned null-like value.'); + return response.data; } } catch (error) { - // �隞亙甇方���隤斗����身�� + // ��ㄐ���隤歹������身�潭���隤方� console.error('An error occurred while closing appointment:', error); throw error; } @@ -119,9 +120,21 @@ // 蝝赤� API async informAppointment(appointmentInformation: ToInformAppointment) { - return http.post(`/notice/send`, appointmentInformation).then((res) => res.data); + try { + const response = await http.post(`/notice/send`, appointmentInformation); + if (response !== null) { + return response.data; + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + console.error('An error occurred while informing appointment:', error); + // �隞亙甇方���隤斗����身�� + throw error; + } } + // �憓�赤閮�� async createInterviewRecord(interviewRecordInfo: InterviewRecordInfo) { try { -- Gitblit v1.9.3