From da37522f55dbab74ba3c3eeed807373b7e97a2f5 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 8 Sep 2026 03:01:38 +0000 Subject: [PATCH 1/3] HF-131: name the cell in the not-computed error (#444) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading a formula cell's value before it has been computed used to throw a bare Error with no way to identify which cell caused it — the literal complaint in issue #444, open since 2020-07-07. Both vertex classes that can throw this (ScalarFormulaVertex and ArrayFormulaVertex, sibling classes in the same file) had the identical defect. CellValueNotComputedError carries the address as a field rather than only in prose, and is re-exported from the package (import block, HyperFormulaNS static, and the bottom export block in src/index.ts) so a consumer can catch it by type, not just by parsing the message. The message itself interpolates numeric sheet/row/col rather than A1-style notation: neither vertex class has access to the sheetIndexMapping that A1-conversion requires, so the field is the deliverable, not the prose. Co-Authored-By: Claude Sonnet 5 --- CHANGELOG.md | 1 + src/DependencyGraph/FormulaVertex.ts | 5 +++-- src/errors.ts | 13 +++++++++++++ src/index.ts | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aea949488..e0f00fd5bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - A cell error read from another cell no longer reports the reading cell as its origin. Errors that come from a cell holding a static error value — a formula with a syntax error, or an error value entered directly — now report that cell's address instead of the address of whichever cell happened to read them first. [#131](https://github.com/handsontable/hyperformula/issues/131) - A parsing error, an error value typed directly into a cell, and an error literal written into a formula are now attributed to `parser`, `user input`, or `literal` respectively, instead of being silently unattributed or (for a parsing error) reporting no address at all. `#SPILL!` errors now report the cell that failed to spill instead of no address. [#131](https://github.com/handsontable/hyperformula/issues/131) +- Reading a formula cell's value before it has been computed now throws a `CellValueNotComputedError` naming the cell's address, instead of a plain `Error` with no way to trace which cell caused it. [#444](https://github.com/handsontable/hyperformula/issues/444) ## [3.4.0] - 2026-08-10 diff --git a/src/DependencyGraph/FormulaVertex.ts b/src/DependencyGraph/FormulaVertex.ts index fbea5f644e..aff74894e4 100644 --- a/src/DependencyGraph/FormulaVertex.ts +++ b/src/DependencyGraph/FormulaVertex.ts @@ -9,6 +9,7 @@ import {ArrayValue, ErroredArray, CellArray, NotComputedArray} from '../ArrayVal import {CellError, equalSimpleCellAddress, ErrorType, SimpleCellAddress} from '../Cell' import {RawCellContent} from '../CellContentParser' import {ErrorMessage} from '../error-message' +import {CellValueNotComputedError} from '../errors' import {EmptyValue, getRawValue, InternalScalarValue, InterpreterValue} from '../interpreter/InterpreterValue' import {LazilyTransformingAstService} from '../LazilyTransformingAstService' import {Maybe} from '../Maybe' @@ -136,7 +137,7 @@ export class ArrayFormulaVertex extends FormulaVertex { getCellValue(): InterpreterValue { if (this.array instanceof NotComputedArray) { - throw Error('Array not computed yet.') + throw new CellValueNotComputedError(this.cellAddress) } return this.array.simpleRangeValue() } @@ -275,7 +276,7 @@ export class ScalarFormulaVertex extends FormulaVertex { if (this.cachedCellValue !== undefined) { return this.cachedCellValue } else { - throw Error('Value of the formula cell is not computed.') + throw new CellValueNotComputedError(this.cellAddress) } } diff --git a/src/errors.ts b/src/errors.ts index 66a73a2add..97840b43c7 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -59,6 +59,19 @@ export class InvalidAddressError extends Error { } } +/** + * Error thrown when a formula cell's value is read before it has been computed. + * + * Carries the address as a field, so callers can trace the cell without parsing + * it back out of the message. The missing address was the complaint in issue #444. + * Thrown by both ScalarFormulaVertex and ArrayFormulaVertex. + */ +export class CellValueNotComputedError extends Error { + constructor(public readonly address: SimpleCellAddress) { + super(`Value of the formula cell (sheet = ${address.sheet}, row = ${address.row}, col = ${address.col}) is not computed.`) + } +} + /** * Error thrown when the given arguments are invalid */ diff --git a/src/index.ts b/src/index.ts index 23b060cf49..4b13a5453e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,7 @@ import { DenseSparseChooseBasedOnThreshold } from './DependencyGraph/AddressMapping/ChooseAddressMappingPolicy' import { + CellValueNotComputedError, ConfigValueTooBigError, ConfigValueTooSmallError, EvaluationSuspendedError, @@ -71,6 +72,7 @@ class HyperFormulaNS extends HyperFormula { public static DetailedCellError = DetailedCellError public static ExportedCellChange = ExportedCellChange public static ExportedNamedExpressionChange = ExportedNamedExpressionChange + public static CellValueNotComputedError = CellValueNotComputedError public static ConfigValueTooBigError = ConfigValueTooBigError public static ConfigValueTooSmallError = ConfigValueTooSmallError public static EvaluationSuspendedError = EvaluationSuspendedError @@ -154,6 +156,7 @@ export { ExportedNamedExpressionChange, DetailedCellError, CellError, + CellValueNotComputedError, ConfigValueTooBigError, ConfigValueTooSmallError, EvaluationSuspendedError, From 87cb6bccfee74ac1f6863fe982b535b7e95b17dc Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 22 Oct 2026 17:25:22 +0000 Subject: [PATCH 2/3] docs: describe CellValueNotComputedError without an issue reference Co-Authored-By: Claude Opus 5.5 --- src/errors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/errors.ts b/src/errors.ts index 97840b43c7..77999ee8d6 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -63,7 +63,7 @@ export class InvalidAddressError extends Error { * Error thrown when a formula cell's value is read before it has been computed. * * Carries the address as a field, so callers can trace the cell without parsing - * it back out of the message. The missing address was the complaint in issue #444. + * it back out of the message. * Thrown by both ScalarFormulaVertex and ArrayFormulaVertex. */ export class CellValueNotComputedError extends Error { From d244d3a2516c77bbd97e8eb2da7ab0e0b7e7302f Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Fri, 23 Oct 2026 00:23:24 +0000 Subject: [PATCH 3/3] HF-131: Start the changelog entry for the not-computed error with the verb Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e6f0f2b7..2150785e76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed the `EDATE` function returning the 28th of February instead of the 29th when the shifted date falls in February of a leap year (e.g. `=EDATE(DATE(2028, 1, 31), 1)` now returns `2028-02-29` instead of `2028-02-28`). [#1781](https://github.com/handsontable/hyperformula/pull/1781) - Fixed a cell holding a static error value, such as a rejected formula or a typed-in error, being reported under the address of the cell that read it first instead of its own address. [#1547](https://github.com/handsontable/hyperformula/issues/1547) - Fixed `#SPILL!` errors reporting no address; their `address` is now the cell whose array result could not spill. [#1547](https://github.com/handsontable/hyperformula/issues/1547) -- Reading a formula cell's value before it has been computed now throws a `CellValueNotComputedError` naming the cell's address, instead of a plain `Error` with no way to trace which cell caused it. [#444](https://github.com/handsontable/hyperformula/issues/444) +- Fixed reading a formula cell's value before it was computed throwing a plain `Error` that did not say which cell it was; it now throws `CellValueNotComputedError`, which carries the cell's address. [#444](https://github.com/handsontable/hyperformula/issues/444) ## [3.5.0] - 2026-10-09