-
Notifications
You must be signed in to change notification settings - Fork 186
Description
In the context of #265, we noticed that any content parsing error could break the build, and considered some way for site builders to tolerate content errors since they come from other authors, particularly with symlinks. This is to work out that design before doing a PR.
All designs have a policy declared as a property on Site, with a default implementation that can be overridden to specify the alternative. During content processing, that property modulates error handling. Previously, any error was thrown, but tolerated errors are printed instead.
Initially it was just to tolerate some error count:
maxContentErrors: Int
/// Whether to tolerate a content error.
public enum ContentErrorTolerance: CustomStringConvertible {
/// No errors are tolerated
case NONE
/// Permit when name has the specified suffix (case-sensitive)
case filename(endsWith: String)
/// Permit when the deploy path has the specified prefix (case-sensitive)
case deployPath(startsWith: String)
/// Permit when the message contains some String
case message(contains: String)
/// Permit up to (and including) a certain number
case upTo(max: Int)
/// Permit when any of these are matched
indirect case anyOf([ContentErrorTolerance])
/// Permit any except for these (i.e., fail if any match)
indirect case anyExcept([ContentErrorTolerance])
public func tolerate(
count: Int,
url: URL,
deployPath: String,
error: any Error
) -> Bool {
...
}
}
Then the name was changed to ContentErrorPolicy and anyOf and anyExcept changed to [ContentErrorPolicy] in #265 (comment)
As an aside in terms of process, I would ask that in discussions, we avoid editing comments or only add edits to the bottom of a comment. E.g., this comment (#265 (comment)) was edited 8 times to change the objection and what was proposed in light of later discussions. I find it disconcerting because I end up wondering why I didn't address the proposal or where the original comment was, when the latest version was written after later discussion and code.