From 252ae33500e8faabb67caeea4a93ea7e50ae98fc Mon Sep 17 00:00:00 2001 From: onevcat Date: Wed, 21 Dec 2016 16:37:30 +0900 Subject: [PATCH] Throw an error instead of fatal error --- APNGKit/Disassembler.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/APNGKit/Disassembler.swift b/APNGKit/Disassembler.swift index eabaebf..089a077 100644 --- a/APNGKit/Disassembler.swift +++ b/APNGKit/Disassembler.swift @@ -75,6 +75,7 @@ public enum DisassemblerError: Error { case pngStructureFailure case pngInternalError case fileSizeExceeded + case invalidAPNGMeta } /** @@ -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) } @@ -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 }