Return errors not nulls when: wrong number of arguments supplied; first argument zero length/empty string

This commit is contained in:
Owen Stephens 2018-02-21 23:19:54 +00:00
parent 2758633f32
commit 5aaf4362b0

View File

@ -39,6 +39,7 @@ import org.json.JSONException;
import org.json.JSONWriter;
import com.google.refine.expr.EvalError;
import com.google.refine.grel.ControlFunctionRegistry;
import com.google.refine.grel.Function;
public class ToNumber implements Function {
@ -58,12 +59,15 @@ public class ToNumber implements Function {
try {
return Double.parseDouble(s);
} catch (NumberFormatException e) {
return new EvalError("Cannot parse to number");
return new EvalError("Unable to parse as number");
}
} else {
return new EvalError("Unable to parse as number");
}
}
} else {
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects one non-null argument");
}
return null;
}
@Override