Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/Jinja/Error.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation

/// Errors that can occur during Jinja template processing.
public enum JinjaError: Error, Sendable {
public enum JinjaError: Error, Sendable, LocalizedError {
/// Error during tokenization of template source.
case lexer(String)
/// Error during parsing of tokens into AST.
Expand All @@ -8,4 +10,13 @@ public enum JinjaError: Error, Sendable {
case runtime(String)
/// Error due to invalid template syntax.
case syntax(String)

public var errorDescription: String? {
switch self {
case .lexer(let message): return "Lexer error: \(message)"
case .parser(let message): return "Parser error: \(message)"
case .runtime(let message): return "Runtime error: \(message)"
case .syntax(let message): return "Syntax error: \(message)"
}
}
}