( error: ArkError, slot: Exclude<ErrorSlot, "expected">, expected: SlotConfig, cited: string | undefined, locale: Locale.Resolved )
| 152 | : config(error as never, locale as never) |
| 153 | |
| 154 | const localeWriter = ( |
| 155 | error: ArkError, |
| 156 | slot: Exclude<ErrorSlot, "expected">, |
| 157 | expected: SlotConfig, |
| 158 | cited: string | undefined, |
| 159 | locale: Locale.Resolved |
| 160 | ): SlotConfig => { |
| 161 | if (cited !== undefined) { |
| 162 | const keywordWriter = keywordWriterOf(error, locale, slot) |
| 163 | if (keywordWriter !== undefined) return keywordWriter |
| 164 | } |
| 165 | const writer = locale[error.code]?.[slot] |
| 166 | if (writer === undefined) return locale[slot] |
| 167 | // a union frames its children's text, unless it cites its own description |
| 168 | // or what it's configured to expect, which is written after `must be` and |
| 169 | // its path as any error's is |
| 170 | if (error.code === "union") { |
| 171 | const framesErrors = |
| 172 | cited === undefined && error.meta?.expected === undefined |
| 173 | return framesErrors || slot === "actual" ? writer : locale[slot] |
| 174 | } |
| 175 | // a code's own message frames its locale's expected, not a keyword's phrase or authored text |
| 176 | if (slot !== "message") return writer |
| 177 | return ( |
| 178 | cited !== undefined || expected !== defaultConfig[error.code].expected |
| 179 | ) ? |
| 180 | locale.message |
| 181 | : writer |
| 182 | } |
| 183 | |
| 184 | const localeExpected = ( |
| 185 | error: ArkError, |
no test coverage detected