Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed PHP Standards and Best Practices!
You have completed PHP Standards and Best Practices!
Preview
Learn how to convert errors in your code into exceptions
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
The benefit here is that sometimes an
error is unavoidable.
0:00
For example, if you try to read a file
that cannot be read,
0:03
it could throw an error.
0:06
If you check to see if that file exists
before you try to read it,
0:08
then you can avoid the error.
0:11
But, in the milliseconds between checking
to see if that file exists and
0:13
actually trying to read that file, it
could have been deleted.
0:16
This is called a race condition.
0:20
And they're no fun at all.
0:21
Sometimes, you need to try and do
something and recover if it goes wrong.
0:23
Converting errors to exceptions lets you
do that.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up