Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

[DX] more helpful exception message in case of invalid value #822

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion src/Spout/Writer/ODS/Manager/WorksheetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ private function getCellXML(Cell $cell, $styleIndex, $numTimesValueRepeated)
} elseif ($cell->isEmpty()) {
$data .= '/>';
} else {
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue()));
$value = $cell->getValueEvenIfError();

throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . (\is_object($value) ? \get_class($value) : \gettype($value)));
}

return $data;
Expand Down
4 changes: 3 additions & 1 deletion src/Spout/Writer/XLSX/Manager/WorksheetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ private function getCellXML($rowIndexOneBased, $columnIndexZeroBased, Cell $cell
$cellXML = '';
}
} else {
throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue()));
$value = $cell->getValueEvenIfError();

throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . (\is_object($value) ? \get_class($value) : \gettype($value)));
andrew-demb marked this conversation as resolved.
Show resolved Hide resolved
}

return $cellXML;
Expand Down