From 27135f3ea3baa242050256d2df44425eb0fe0fed Mon Sep 17 00:00:00 2001 From: Ilya Puchka Date: Wed, 29 Nov 2017 23:41:18 +0100 Subject: [PATCH] changer Never return type to Error in ErrorReporter this resolves warning related to Never type --- Sources/Environment.swift | 4 ++-- Sources/Errors.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Environment.swift b/Sources/Environment.swift index 611e14e..d612ae4 100644 --- a/Sources/Environment.swift +++ b/Sources/Environment.swift @@ -47,7 +47,7 @@ public struct Environment { do { return try template.render(context) } catch { - try errorReporter.report(error: error) + throw errorReporter.reportError(error) } } @@ -66,7 +66,7 @@ public struct Environment { do { return try closure() } catch { - try errorReporter.report(error: error) + throw errorReporter.reportError(error) } } diff --git a/Sources/Errors.swift b/Sources/Errors.swift index 8fb988e..97e93b7 100644 --- a/Sources/Errors.swift +++ b/Sources/Errors.swift @@ -46,17 +46,17 @@ public class ErrorReporterContext { public protocol ErrorReporter: class { var context: ErrorReporterContext! { get set } - func report(error: Error) throws -> Never + func reportError(_ error: Error) -> Error func contextAwareError(_ error: TemplateSyntaxError, context: ErrorReporterContext) -> Error? } open class SimpleErrorReporter: ErrorReporter { public var context: ErrorReporterContext! - open func report(error: Error) throws -> Never { - guard let syntaxError = error as? TemplateSyntaxError else { throw error } - guard let context = context else { throw error } - throw contextAwareError(syntaxError, context: context) ?? error + open func reportError(_ error: Error) -> Error { + guard let syntaxError = error as? TemplateSyntaxError else { return error } + guard let context = context else { return error } + return contextAwareError(syntaxError, context: context) ?? error } // TODO: add stack trace using parent context