Skip to content

Commit

Permalink
Throw an error instead of fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Dec 21, 2016
1 parent 9ba3918 commit 252ae33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions APNGKit/Disassembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public enum DisassemblerError: Error {
case pngStructureFailure
case pngInternalError
case fileSizeExceeded
case invalidAPNGMeta
}

/**
Expand Down Expand Up @@ -358,7 +359,7 @@ class Disassembler {
frames.append(frame)
}
guard let apngMeta = apngMeta else {
fatalError("The APNG meta should exists.")
throw DisassemblerError.invalidAPNGMeta
}
return (frames, apngMeta)
}
Expand All @@ -367,7 +368,9 @@ class Disassembler {
try prepare()
clean()

guard let apngMeta = apngMeta else { fatalError("The apng meta should exists") }
guard let apngMeta = apngMeta else {
throw DisassemblerError.invalidAPNGMeta
}
return apngMeta
}

Expand Down

0 comments on commit 252ae33

Please sign in to comment.