Blog/wwwroot/jsonql-js/errors.js 772 B · 25 lines · raw · history
| 1 | /** Thrown while tokenizing or parsing an expression. */ |
| 2 | export class SqlSyntaxError extends Error { |
| 3 | /** |
| 4 | * @param {string} message |
| 5 | * @param {{pos?: number, line?: number, col?: number}} [location] |
| 6 | */ |
| 7 | constructor(message, location = {}) { |
| 8 | const { pos, line, col } = location; |
| 9 | const suffix = line != null ? ` (line ${line}, col ${col})` : ''; |
| 10 | super(`${message}${suffix}`); |
| 11 | this.name = 'SqlSyntaxError'; |
| 12 | this.pos = pos; |
| 13 | this.line = line; |
| 14 | this.col = col; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /** Thrown while evaluating a parsed expression against data (type errors, unknown functions, etc). */ |
| 19 | export class SqlEvaluationError extends Error { |
| 20 | /** @param {string} message */ |
| 21 | constructor(message) { |
| 22 | super(message); |
| 23 | this.name = 'SqlEvaluationError'; |
| 24 | } |
| 25 | } |