From the course: Java Exception Handling

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Handle potential runtime exceptions

Solution: Handle potential runtime exceptions - Java Tutorial

From the course: 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,…

Contents