Skip to content

Commit 07787e0

Browse files
committed
Throw a exception when user contains mistake to call aspectRatio with non-positive values. This is exist behavior of SwiftUI's Image (But the exception is different)
1 parent bd635fd commit 07787e0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ extension AnimatedImage {
496496
var ratio: CGFloat?
497497
if aspectRatio.width > 0 && aspectRatio.height > 0 {
498498
ratio = aspectRatio.width / aspectRatio.height
499+
} else {
500+
NSException(name: .invalidArgumentException, reason: "\(type(of: self)).\(#function) should be called with positive aspectRatio", userInfo: nil).raise()
499501
}
500502
return self.aspectRatio(ratio, contentMode: contentMode)
501503
}

0 commit comments

Comments
 (0)