Skip to content

Commit 3263de8

Browse files
committed
fix: better and more verbose error message on failed write
1 parent 2489d9e commit 3263de8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/CsvFile.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ public function writeRow(array $row)
323323
as an error. Therefore both conditions are necessary. */
324324
if (($ret === false) || (($ret === 0) && (strlen($str) > 0))) {
325325
throw new Exception(
326-
"Cannot write to file {$this->getPathname()}",
326+
"Cannot write to CSV file " . $this->getPathname() .
327+
' Error: ' . error_get_last()['message'] . ' Return: ' . json_encode($ret) .
328+
' To write: ' . strlen($str) . ' Written: ' . $ret,
327329
Exception::WRITE_ERROR,
328330
null,
329331
Exception::WRITE_ERROR_STR

0 commit comments

Comments
 (0)