From c0e4aa6bddb7b54c6d07545fe55655f29ce1bc0d Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Fri, 19 Jul 2024 09:26:43 -0700 Subject: [PATCH] fix merge --- .../crt/CommonRuntimeError.swift | 14 -------------- Source/AwsCommonRuntimeKit/crt/Utilities.swift | 8 ++++---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Source/AwsCommonRuntimeKit/crt/CommonRuntimeError.swift b/Source/AwsCommonRuntimeKit/crt/CommonRuntimeError.swift index e41eeb99..56de85a3 100644 --- a/Source/AwsCommonRuntimeKit/crt/CommonRuntimeError.swift +++ b/Source/AwsCommonRuntimeKit/crt/CommonRuntimeError.swift @@ -27,20 +27,6 @@ public struct CRTError: Equatable { self.name = String(cString: aws_error_name(self.code)) } - public init(code: T, context: String?) { - if code > INT32_MAX || code < 0 { - self.code = Int32(AWS_ERROR_UNKNOWN.rawValue) - } else { - self.code = Int32(code) - } - var message = String(cString: aws_error_str(self.code)) - if let context { - message += ": " + context - } - self.message = message - self.name = String(cString: aws_error_name(self.code)) - } - public static func makeFromLastError() -> CRTError { return CRTError(code: aws_last_error()) } diff --git a/Source/AwsCommonRuntimeKit/crt/Utilities.swift b/Source/AwsCommonRuntimeKit/crt/Utilities.swift index 796f3bd7..52624848 100644 --- a/Source/AwsCommonRuntimeKit/crt/Utilities.swift +++ b/Source/AwsCommonRuntimeKit/crt/Utilities.swift @@ -148,7 +148,7 @@ extension TimeInterval { let _millisecond = (self * 1_000).rounded() guard _millisecond >= 0 && _millisecond <= Double(UInt32.max) else { // todo convert the millisecond conversion errors into aws-crt-swift errors - throw CommonRunTimeError.crtError(CRTError(code: AWS_CRT_SWIFT_INVALID_ARGUMENT.rawValue)) + throw CommonRunTimeError.crtError(CRTError(code: AWS_ERROR_INVALID_ARGUMENT.rawValue)) } return UInt32(_millisecond) } @@ -157,7 +157,7 @@ extension TimeInterval { let _millisecond = (self * 1_000).rounded() guard _millisecond >= 0 && _millisecond <= Double(UInt64.max) else { // todo convert the millisecond conversion errors into aws-crt-swift errors - throw CommonRunTimeError.crtError(CRTError(code: AWS_CRT_SWIFT_INVALID_ARGUMENT.rawValue)) + throw CommonRunTimeError.crtError(CRTError(code: AWS_ERROR_INVALID_ARGUMENT.rawValue)) } return UInt64(_millisecond) } @@ -165,7 +165,7 @@ extension TimeInterval { func secondUInt16() throws -> UInt16 { guard self >= 0 && self <= Double(UInt16.max) else { // todo convert the millisecond conversion errors into aws-crt-swift errors - throw CommonRunTimeError.crtError( CRTError(code: AWS_CRT_SWIFT_INVALID_ARGUMENT.rawValue)) + throw CommonRunTimeError.crtError( CRTError(code: AWS_ERROR_INVALID_ARGUMENT.rawValue)) } return UInt16(self) } @@ -173,7 +173,7 @@ extension TimeInterval { func secondUInt32() throws -> UInt32 { guard self >= 0 && self <= Double(UInt32.max) else { // todo convert the millisecond conversion errors into aws-crt-swift errors - throw CommonRunTimeError.crtError( CRTError(code: AWS_CRT_SWIFT_INVALID_ARGUMENT.rawValue)) + throw CommonRunTimeError.crtError( CRTError(code: AWS_ERROR_INVALID_ARGUMENT.rawValue)) } return UInt32(self) }