changer Never return type to Error in ErrorReporter
this resolves warning related to Never type
This commit is contained in:
@@ -47,7 +47,7 @@ public struct Environment {
|
|||||||
do {
|
do {
|
||||||
return try template.render(context)
|
return try template.render(context)
|
||||||
} catch {
|
} catch {
|
||||||
try errorReporter.report(error: error)
|
throw errorReporter.reportError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public struct Environment {
|
|||||||
do {
|
do {
|
||||||
return try closure()
|
return try closure()
|
||||||
} catch {
|
} catch {
|
||||||
try errorReporter.report(error: error)
|
throw errorReporter.reportError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,17 +46,17 @@ public class ErrorReporterContext {
|
|||||||
|
|
||||||
public protocol ErrorReporter: class {
|
public protocol ErrorReporter: class {
|
||||||
var context: ErrorReporterContext! { get set }
|
var context: ErrorReporterContext! { get set }
|
||||||
func report(error: Error) throws -> Never
|
func reportError(_ error: Error) -> Error
|
||||||
func contextAwareError(_ error: TemplateSyntaxError, context: ErrorReporterContext) -> Error?
|
func contextAwareError(_ error: TemplateSyntaxError, context: ErrorReporterContext) -> Error?
|
||||||
}
|
}
|
||||||
|
|
||||||
open class SimpleErrorReporter: ErrorReporter {
|
open class SimpleErrorReporter: ErrorReporter {
|
||||||
public var context: ErrorReporterContext!
|
public var context: ErrorReporterContext!
|
||||||
|
|
||||||
open func report(error: Error) throws -> Never {
|
open func reportError(_ error: Error) -> Error {
|
||||||
guard let syntaxError = error as? TemplateSyntaxError else { throw error }
|
guard let syntaxError = error as? TemplateSyntaxError else { return error }
|
||||||
guard let context = context else { throw error }
|
guard let context = context else { return error }
|
||||||
throw contextAwareError(syntaxError, context: context) ?? error
|
return contextAwareError(syntaxError, context: context) ?? error
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add stack trace using parent context
|
// TODO: add stack trace using parent context
|
||||||
|
|||||||
Reference in New Issue
Block a user