Skip to content

Comments

Add error checking for file I/O operations in ReportCommand#12

Closed
Copilot wants to merge 2 commits intonextfrom
copilot/sub-pr-10-again
Closed

Add error checking for file I/O operations in ReportCommand#12
Copilot wants to merge 2 commits intonextfrom
copilot/sub-pr-10-again

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Addresses feedback from PR #10 review: file operations (mkdir, copy, file_put_contents) lacked failure checks, causing silent failures or generic PHP warnings on permission/disk space issues.

Changes:

  • Wrap all file I/O operations in error checks that throw RuntimeException on failure
  • Include file path and common failure causes (permissions, disk space) in error messages
  • Applied to: directory creation, report.js/chart.js/styles.css/index.html writes, and asset copies

Example:

// Before
file_put_contents($destination, 'const reportData = '.$json.';');

// After
if (false === file_put_contents($destination, 'const reportData = '.$json.';')) {
    throw new \RuntimeException(sprintf('Failed to write report data to "%s". Check permissions and disk space.', $destination));
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: makomweb <1567373+makomweb@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on CLI command to generate a report Add error checking for file I/O operations in ReportCommand Jan 25, 2026
Copilot AI requested a review from makomweb January 25, 2026 14:45
Copy link
Owner

@makomweb makomweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please close this one. I have applied changes manually due to other changes making it less necessary to apply these changes.

Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

Please close this one. I have applied changes manually due to other changes making it less necessary to apply these changes.

Understood. This PR can be closed as you've applied the changes manually.

Copilot AI requested a review from makomweb January 25, 2026 15:03
@makomweb makomweb closed this Jan 25, 2026
@makomweb makomweb deleted the copilot/sub-pr-10-again branch January 25, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants