• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Functions and Exceptions

 
Ranch Hand
Posts: 163
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All, I am reading OCP book by Jeanne, and i found one of the code is not working and is as below:



The try catch in lambdas is still asking me to return something after catch.

@Jeanne, how to handle this type of exceptions

Thanks & Regards,

Swapna
 
Marshal
Posts: 76811
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, you are getting a compiler error. Please go through all the possible paths of execution. There aren't many, in fact two, depending on whether the try does or doesn't complete with an exception.
 
Swapna latha
Ranch Hand
Posts: 163
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna latha wrote:Hi All, I am reading OCP book by Jeanne, and i found one of the code is not working and is as below:



The try catch in lambdas is still asking me to return something after catch.

@Jeanne, how to handle this type of exceptions

Thanks & Regards,

Swapna



Sorry, i got the exception resolved. In catch block, if i throw new RuntimeException , then i wont be getting compilter error. Jeanne has given the correct code, its my bad and i have not observed it.

Thanks Campbell for immediate response.
 
Campbell Ritchie
Marshal
Posts: 76811
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna latha wrote:. . . Jeanne has given the correct code, its my bad and i have not observed it.

Please show us what the book actually says.

Thanks Campbell for immediate response.

That's a pleasure
 
I want my playground back. Here, I'll give you this tiny ad for it:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic