课程: Java Exception Handling

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Handle potential runtime exceptions

Solution: Handle potential runtime exceptions - Java教程

课程: Java Exception Handling

Solution: Handle potential runtime exceptions

(upbeat music) - [Instructor] For this challenge, you were tasked with updating any parts of a controller that can encounter an exception. You were to catch these generic exceptions and returning more helpful message to our users. There are a total of four endpoints in our app. We already worked through an example with the findNumber endpoint on line 24. This means you have three endpoints left, that could be updated. Simply put, we could just add this exception catch clause, between line 31 and 34, to any of the existing try-catches that we have, and if a try-catch does not already exist, we can just create one specifically. So to not reinvent the wheel, I'm going to copy lines 31 through 34 and find our next try-catch. So if you recall before, I said handling an NPE like this is not ideal. So I'm actually going to get rid of lines 51 through 54, for createSequence endpoint. And instead use this exception,…

内容