You have a function from the library (already in the task scope). You can't find the source code, but you know the prototype of the function. The library developer kindly left a comment, but we can't guarantee that the function will return only this error.
/*
* The function can throw an IllegalArgumentException if the argument is incorrect
*/
def parseSpecialNumber(s: String): Int
Fix our tryPrintSpecialNumber function to fulfill the following conditions:
- If there is an
IllegalArgumentExceptionthrown byparseSpecialNumber, we throw the error back so that other code handles it - If there is any other error, we print its message
- If the function is completed successfully, just print the result