Function
formatErrorMessage
(source: string, detail: string, position: number)
Source from the content-addressed store, hash-verified
| 56 | } |
| 57 | |
| 58 | function formatErrorMessage(source: string, detail: string, position: number): string { |
| 59 | const clamped = Number.isFinite(position) |
| 60 | ? Math.min(Math.max(0, Math.trunc(position)), source.length) |
| 61 | : 0; |
| 62 | const caret = `${" ".repeat(8 + clamped)}^`; |
| 63 | return `${detail} at position ${String(clamped)}\n expr("${source}")\n${caret}`; |
| 64 | } |
| 65 | |
| 66 | export class ConstraintSyntaxError extends Error { |
| 67 | readonly source: string; |
Tested by
no test coverage detected