(expr: Expression | undefined | null)
| 241 | if (expr === undefined) return 'UNDEFINED'; |
| 242 | if (expr === null) return 'NULL'; |
| 243 | |
| 244 | errors = []; |
| 245 | let result = ''; |
| 246 | try { |
| 247 | result = engine.expr(expr)?.latex ?? 'NULL'; |
| 248 | } catch (e) { |
| 249 | errors.push(e.toString()); |
| 250 | } |
| 251 | if (result && errors.length !== 0) return result + '\n' + errors.join('\n'); |
| 252 | if (errors.length !== 0) return errors.join('\n'); |
| 253 | return result; |
| 254 | } |
| 255 | |
| 256 | export function expressionError(latex: string): string | string[] { |
| 257 | errors = []; |
| 258 | engine.parse(latex); |
| 259 | return errors.length === 1 ? errors[0] : errors; |
| 260 | } |
no test coverage detected