Exception: Falling with style. Error: Failing with smile
Andy learning to code. He seemed a little worried. Mike happens to stop by.
"You seem worried. What’s on your mind?" asked Mike.
"Well Mike, I’ve been trying to understand exception handling. But I can’t seem to wrap my head around it." answered Andy.
Mike laughed and said "I see. Come with me. First we will watch a video, then, I’ll explain."
Andy was excited! They watched the following clip from the movie "Toy Story".
After the video ended, Mike said with a smile "So Andy, now let’s discuss exception handling. You know that Buzz cannot fly, he knows that too. But when the rocket is about to blow up him and Woody, he manipulates the situation and uses its force to propel them to the safety of the car!! Two things happen - One, the rocket doesn't kill them. Second, they land in their desired spot! In Buzz’s words, they were falling with style!!!"
"I get that. But how does that explain exception handling?" wondered Andy.
"You see Andy, what Buzz did was ‘exception handling’. When the standard code does not yield the expected output due to some uncontrollable factors; you can use a smart code to handle the exception to your advantage. Thereby, avoiding an unpleasant user experience."
"Now I see your point Mike. Exception handling is nothing but "falling with style!!!"