Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Hints on OOP-2

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I seem to be going around in circles and when I solve a problem one way I hit another which I have already been nitpicked on. If anyone could give me some hints on getting past this I would be very very grateful
Anyway I have my try and catch in the main but now have a method to handle the splitting of input this leads to the problem - I either need to return 2 things, have a global variable or an array to hold the bits. These have all been nitpicked so I am onto my new approach to call the toInt from within this method however I need to catch the exception in main() not this new method...
Any hints??
Thanks
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the question is how to get the exception to show up in main if it occurs in toInt?
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is how do I catch the exception in main when toInt is called by a different method?
It seems to me that this method shouldn't call toInt but then I have the problem of needing (or wanting) to return more than one thing back to main
 
John Hembree
hired gun
Ranch Hand
Posts: 250
MS IE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In mine, main called toInt and toInt called the get function, then when a exception would occur in toInt, I would catch it and then throw a new exception with my text to send to the client. Hope that's a hint that's as thick as mud.
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you just let the original exception percolate up? In the method that throws the exception, throw your own exception that says what you want to say. Let it pass through the intermediate method up to main where you catch and display the exception with the message.
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I might have just had one of those seeing the light moments, thanks for the hints
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic