(raw: string)
| 220 | }; |
| 221 | |
| 222 | export const normalizeCliErrorText = (raw: string): string => { |
| 223 | const lines = raw.split(/\r?\n/); |
| 224 | const compacted: Array<string> = []; |
| 225 | |
| 226 | for (const line of lines) { |
| 227 | const trimmed = line.trim(); |
| 228 | if (trimmed.length === 0) { |
| 229 | if (compacted.length > 0 && compacted[compacted.length - 1] !== "") { |
| 230 | compacted.push(""); |
| 231 | } |
| 232 | continue; |
| 233 | } |
| 234 | if (/^at\s+/.test(trimmed)) continue; |
| 235 | if (/^From previous event/.test(trimmed)) continue; |
| 236 | compacted.push(trimmed); |
| 237 | } |
| 238 | |
| 239 | if (compacted.length === 0) { |
| 240 | return stripRepeatedErrorPrefix(raw); |
| 241 | } |
| 242 | |
| 243 | compacted[0] = stripRepeatedErrorPrefix(compacted[0] ?? ""); |
| 244 | while (compacted.length > 0 && compacted[0]?.length === 0) { |
| 245 | compacted.shift(); |
| 246 | } |
| 247 | |
| 248 | const limited = compacted.slice(0, 24); |
| 249 | return limited.join("\n").trim(); |
| 250 | }; |
| 251 | |
| 252 | export interface PausedInteraction { |
| 253 | readonly kind: "url" | "form"; |
no test coverage detected