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

[8.x] Add default parameter to throw_if / throw_unless #35888

Closed
wants to merge 1 commit into from
Closed

[8.x] Add default parameter to throw_if / throw_unless #35888

wants to merge 1 commit into from

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Jan 14, 2021

This PR adds a default parameter to throw_if and throw_unless:

// Currently:
throw_if($somethingIsWrong, new RuntimeException);

// With this PR:
throw_if($somethingIsWrong);

I use throw_if to guard against incorrect situations in non-user facing code. In my case. In most situations I don't care about the specific exception class, or about the exception message. I just want my code to stop running and write a stacktrace to the log file.

@taylorotwell
Copy link
Member

Hmm... really seems like you would want a message... I would almost prefer the argument except a string optionally like the @freekmurze updated the report method.

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