minor code refactoring

This commit is contained in:
Ilya Puchka
2017-12-27 19:29:17 +01:00
parent 662849e968
commit d6766b43da
5 changed files with 58 additions and 60 deletions

View File

@@ -44,6 +44,17 @@ public struct TemplateSyntaxError : Error, Equatable, CustomStringConvertible {
}
extension Error {
func withToken(_ token: Token?) -> Error {
if var error = self as? TemplateSyntaxError {
error.token = error.token ?? token
return error
} else {
return TemplateSyntaxError(reason: "\(self)", token: token)
}
}
}
public protocol ErrorReporter: class {
func renderError(_ error: Error) -> String
}