added parent context to ErrorReporterContext and handling errors in include and extend nodes
This commit is contained in:
@@ -48,7 +48,6 @@ public struct Environment {
|
||||
return try template.render(context)
|
||||
} catch {
|
||||
try errorReporter.report(error: error)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +55,19 @@ public struct Environment {
|
||||
return errorReporter.context?.template
|
||||
}
|
||||
|
||||
|
||||
public func pushTemplate<Result>(_ template: Template, token: Token, closure: (() throws -> Result)) rethrows -> Result {
|
||||
let errorReporterContext = errorReporter.context
|
||||
defer { errorReporter.context = errorReporterContext }
|
||||
errorReporter.context = ErrorReporterContext(
|
||||
template: template,
|
||||
parent: errorReporterContext != nil ? (errorReporterContext!, token) : nil
|
||||
)
|
||||
do {
|
||||
return try closure()
|
||||
} catch {
|
||||
try errorReporter.report(error: error)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user