(core) Add CellError to explain when a formula refers to a cell with an error value

Summary:
get_cell_value wraps RaisedException with CellError to expand the error message for the user.

This is still pretty conceptual, the comments explain some things to think about, but it works and is an improvement.

Test Plan: Updated Python unit tests

Reviewers: dsagal, paulfitz

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2928
This commit is contained in:
Alex Hall
2021-07-30 20:51:56 +02:00
parent 1605e18f66
commit 0e5c2bee59
4 changed files with 51 additions and 8 deletions

View File

@@ -147,7 +147,12 @@ class BaseColumn(object):
"""
raw = self.raw_get(row_id)
if isinstance(raw, objtypes.RaisedException):
raise raw.error
if isinstance(raw.error, depend.CircularRefError):
# Wrapping a CircularRefError in a CellError is often redundant, but
# TODO a CellError is still useful if the calling cell is not involved in the cycle
raise raw.error
else:
raise objtypes.CellError(self.table_id, self.col_id, row_id, raw.error)
if self.type_obj.is_right_type(raw):
return self._make_rich_value(raw)
return usertypes.AltText(str(raw), self.type_obj.typename())