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

Conversation

andrew-demb
Copy link
Contributor

It is should provide a more helpful message for developer in exception, when in cell value provided an object.

Example:

Exception:

Uncaught PHP Exception Box\\Spout\\Common\\Exception\\InvalidArgumentException: \"Trying to add a value with an unsupported type: NULL\" at /project/vendor/box/spout/src/Spout/Writer/XLSX/Manager/WorksheetManager.php line 256

I may assume, that in my code somewhere used null and passed to spout, but the real reason was - object was provided for cell value, and this lead to described above exception.

This PR will improve an error message and provide a better DX.

…helpful exception message (in case of objects, for example)
@adrilo
Copy link
Collaborator

adrilo commented Jun 22, 2021

Hi!
I believe that your interpretation may not be correct. gettype($object) should return "object" and not "NULL" like you describe. Only gettype(null) returns "NULL".
So here, it seems like a NULL value is passed in.

@andrew-demb
Copy link
Contributor Author

Yes, it was output NULL because $cell->getValue() returned null, but this method return null, because resolved cell type was an error

So PR propose change $cell->getValue() to $cell->getValueEvenIfError() AND explain object class name, when it is contained in value.

@andrew-demb
Copy link
Contributor Author

Probably Travis CI check should be retried because PR check status was not changed to finished status.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants