Current Status
Phase: implemented
Last updated: 2026-05-02
Implementation: PR #35 / commit e63baaa
Verification: swift build; focused swift test --filter InsertLocationTests|ParagraphTests|Issue56RoundtripCompletenessTests|Issue6RoundtripLoudFailTests; full swift test (830 tests, 1 skipped, 0 failures)
Notes: InsertLocationError now conforms to LocalizedError; every case has a human-readable errorDescription, with unit coverage for each case.
Problem
From verification of #91 (Devil's Advocate DA-2):
「InsertLocationError lacks LocalizedError conformance — sibling enums CommentError / FootnoteError / EndnoteError all conform. Missed opportunity to ship a human-readable message for the new case.」
— Source: team:devils-advocate
Type
enhancement
Background
InsertLocationError (Sources/OOXMLSwift/Models/InsertLocation.swift:28-42) currently:
public enum InsertLocationError: Error, Equatable {
case invalidParagraphIndex(Int)
case imageIdNotFound(String)
case tableIndexOutOfRange(Int)
case tableCellOutOfRange(tableIndex: Int, row: Int, col: Int)
case textNotFound(searchText: String, instance: Int)
case inlineModeRequiresParagraphIndex // post-#91
}
Sibling enums in the same package (CommentError, FootnoteError, EndnoteError) all conform to LocalizedError and provide errorDescription strings. InsertLocationError is the odd one out — callers using error.localizedDescription get the case name string instead of a human-readable message.
Expected
extension InsertLocationError: LocalizedError {
public var errorDescription: String? {
switch self {
case .invalidParagraphIndex(let idx):
return "Paragraph index \(idx) is out of range for the document."
case .imageIdNotFound(let rId):
return "No image with relationship id '\(rId)' was found in the document."
case .tableIndexOutOfRange(let idx):
return "Table index \(idx) is out of range for the document."
case .tableCellOutOfRange(let tableIdx, let row, let col):
return "Table cell (table \(tableIdx), row \(row), col \(col)) is out of range."
case .textNotFound(let searchText, let instance):
return "Could not find instance \(instance) of text '\(searchText)' in the document."
case .inlineModeRequiresParagraphIndex:
return "Inline equations only support paragraphIndex anchors. Use a different anchor type or switch to displayMode: true."
}
}
}
Effort
Trivial — ~20 LOC + 1 test asserting errorDescription is non-nil for each case.
Related
Current Status
Phase: implemented
Last updated: 2026-05-02
Implementation: PR #35 / commit
e63baaaVerification:
swift build; focusedswift test --filter InsertLocationTests|ParagraphTests|Issue56RoundtripCompletenessTests|Issue6RoundtripLoudFailTests; fullswift test(830 tests, 1 skipped, 0 failures)Notes:
InsertLocationErrornow conforms toLocalizedError; every case has a human-readableerrorDescription, with unit coverage for each case.Problem
Type
enhancement
Background
InsertLocationError(Sources/OOXMLSwift/Models/InsertLocation.swift:28-42) currently:Sibling enums in the same package (
CommentError,FootnoteError,EndnoteError) all conform toLocalizedErrorand provideerrorDescriptionstrings.InsertLocationErroris the odd one out — callers usingerror.localizedDescriptionget the case name string instead of a human-readable message.Expected
Effort
Trivial — ~20 LOC + 1 test asserting
errorDescriptionis non-nil for each case.Related
CommentError.LocalizedError,FootnoteError.LocalizedError,EndnoteError.LocalizedError