From 2248b4a1676a118d4066b40a4dc5d266c8130e95 Mon Sep 17 00:00:00 2001 From: shinhong_park Date: Sat, 12 Oct 2024 16:57:40 +0900 Subject: [PATCH] Check cancellation before reporting error --- SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift b/SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift index 899419ac..b833ae33 100644 --- a/SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift +++ b/SNUTT-2022/SNUTT/Repositories/NetworkUtils.swift @@ -115,6 +115,7 @@ extension DataTask { if let data = await response.data, let errDto = try? JSONDecoder().decode(ErrorDto.self, from: data) { + try Task.checkCancellation() let errCode = ErrorCode(rawValue: errDto.errcode) var requestInfo = await collectRequestInfo() requestInfo["ErrorMessage"] = errCode?.errorMessage @@ -129,13 +130,13 @@ extension DataTask { throw STError(errCode ?? .SERVER_FAULT) } } - if let dto = try? await value { return dto } - + try Task.checkCancellation() let requestInfo = await collectRequestInfo() Crashlytics.crashlytics().record(error: NSError(domain: "UNKNOWN_ERROR", code: -1, userInfo: requestInfo)) + try Task.checkCancellation() throw STError(.SERVER_FAULT) }