name:
src/main/js/formulas/info/ERRORTYPE.ts
-rw-r--r--
1131
1import { F7Exception } from "../../errors/F7Exception";
2import { getExceptionCode } from "../../errors/F7ExceptionName";
3import { NAException } from "../../errors/NAException";
4import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
5import { Complex } from "../../models/common/Types";
6import { Converters } from "../../utils/Converters";
7import { AbstractFormula } from "../AbstractFormula";
8import { FormulaName } from "../FormulaName";
9
10export class ERRORTYPE extends AbstractFormula {
11 static SELF: ERRORTYPE = new ERRORTYPE();
12 NAME = FormulaName.ERRORTYPE;
13
14 internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
15 AbstractFormula.checkLength(values.length, 1, this.NAME);
16 try {
17 const first = Converters.first(this.collateralLookup(origin, values[0]));
18 if (first instanceof F7Exception) {
19 return getExceptionCode(Converters.castAsF7Exception(first).name);
20 }
21 return new NAException("Formula ERRORTYPE parameter 1 is not an error.");
22 } catch (error) {
23 return getExceptionCode(Converters.castAsF7Exception(error as F7Exception).name);
24 }
25 }
26}