aspose file tools*
The moose likes Cattle Drive and the fly likes Need Hints on OOP-2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Need Hints on OOP-2" Watch "Need Hints on OOP-2" New topic
Author

Need Hints on OOP-2

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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

Joined: Jul 22, 2000
Posts: 9046
    
  10
So the question is how to get the exception to show up in main if it occurs in toInt?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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

Joined: Mar 07, 2003
Posts: 250

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

Joined: Jul 22, 2000
Posts: 9046
    
  10
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

Joined: Apr 02, 2003
Posts: 280
I think I might have just had one of those seeing the light moments, thanks for the hints
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Hints on OOP-2