Skip to content

Implement the used of Exception codes in the calculation engine #1541

Open
@MarkBaker

Description

@MarkBaker

This is:

- [ ] a bug report
- [X] a feature request

Exceptions in the calculation engine simply return a text message identifying the problem, and any related values, e.g. "undefined name ''NAMED_RANGE", where NAMED_RANGE is used in a formula, but hasn't actually been defined.
We catch this in getCalculatedValue() but have to assess the text of the message in order to convert it into a #NAME? response.
It would be easier if we could use exception codes to make the exception easier to identify and determine an appropriate return value for the different potential exceptions that could be thrown. A simple mapping of exception codes to responses would provide a much easier implementation (and be more efficient) than a long list of if tests, each with its own strpos() check.

This also allows for differentiating between a function that returns a genuine string value of #NAME?, and a genuine #NAME? error when evaluating a formula. At present, a string of #NAME? is treated as an exception.

Potentially the next step after that is to modify the PHP implementation of Excel functions to throw coded exceptions rather than returning "exception strings", and the parser could then be modified to assess exception or string correctly in formulae like IFERROR(12 / A1, "Cell A1 contains a zero value") much more cleanly

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions