]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/IfErrorFormulaFunction.java
Improved exception message
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / formula / IfErrorFormulaFunction.java
1 package org.simantics.spreadsheet.graph.formula;
2
3 import org.simantics.spreadsheet.graph.CellFormulaFunction;
4 import org.simantics.spreadsheet.graph.CellValueVisitor;
5 import org.simantics.spreadsheet.graph.parser.ast.AstArgList;
6
7 public class IfErrorFormulaFunction implements CellFormulaFunction<Object> {
8         
9         @Override
10     public Object evaluate(CellValueVisitor visitor, AstArgList args) {
11                 
12         if (args.values.size() != 2) throw new IllegalStateException();
13         
14         Object condition = args.values.get(0).accept(visitor);
15         FormulaError2 error = FormulaError2.forObject(condition);
16         if(error!=null) return error.getString();
17         else return condition;
18     }
19 }