Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Jul 19, 2024
1 parent 425260a commit c0e4aa6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
14 changes: 0 additions & 14 deletions Source/AwsCommonRuntimeKit/crt/CommonRuntimeError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ public struct CRTError: Equatable {
self.name = String(cString: aws_error_name(self.code))
}

public init<T: BinaryInteger>(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())
}
Expand Down
8 changes: 4 additions & 4 deletions Source/AwsCommonRuntimeKit/crt/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -157,23 +157,23 @@ 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)
}

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)
}

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)
}
Expand Down

0 comments on commit c0e4aa6

Please sign in to comment.