reporting error with its parent context

This commit is contained in:
Ilya Puchka
2017-12-24 15:34:17 +01:00
parent 53c1550c5b
commit 9a28142fa6
6 changed files with 161 additions and 44 deletions

View File

@@ -27,9 +27,17 @@ class IncludeNode : NodeType {
let template = try context.environment.loadTemplate(name: templateName)
return try context.environment.pushTemplate(template, token: token) {
try context.push {
return try template.render(context)
do {
return try context.environment.pushTemplate(template, token: token) {
try context.push {
return try template.render(context)
}
}
} catch {
if let parentError = error as? TemplateSyntaxError {
throw TemplateSyntaxError(reason: parentError.reason, parentError: parentError)
} else {
throw error
}
}
}