Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filesystem - read_file - InvariantViolationException message should contains filename #204

Closed
vaclavvanik opened this issue Jun 3, 2021 · 4 comments · Fixed by #205
Closed
Assignees
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes.
Milestone

Comments

@vaclavvanik
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When I try to read_file which does not exist, is not file or is not readable InvariantViolationException is thrown with message like $file does not exist.

I would like to see given filename in exception message. It's than easier to debug and fix possible problem.

Describe the solution you'd like

Replace

Psl\invariant(exists($file), '$file does not exist.');

with

Psl\invariant(exists($file), Str\format('File "%s" does not exist.', $file));

Thrown RuntimeException contains provided $file too.

@vaclavvanik vaclavvanik added the Type: Enhancement Most issues will probably ask for additions or changes. label Jun 3, 2021
@azjezz azjezz added Priority: Medium This issue may be useful, and needs some attention. Status: Available No one has claimed responsibility for resolving this issue. labels Jun 3, 2021
@azjezz azjezz added this to the 1.8.0 milestone Jun 3, 2021
@azjezz
Copy link
Owner

azjezz commented Jun 3, 2021

I'm pretty sure this is done in multiple other places as well.

would you like to send a PR? :)

@vaclavvanik
Copy link
Contributor Author

Sure, I will create PR. Which branch should I target?

@azjezz
Copy link
Owner

azjezz commented Jun 3, 2021

1.8.x since it's not a bug :)

@azjezz
Copy link
Owner

azjezz commented Jun 3, 2021

Note: instead of Psl\invariant($fact, Str\format($message, ...$args)); you should do Psl\invariant($fact, $message, ...$args); ( the message will be formatted only if the $fact is false.

@azjezz azjezz added Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness and removed Status: Available No one has claimed responsibility for resolving this issue. labels Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants