The online racing simulator
[OT] Java: Problematic Exceptions
Don't worry, I've solved it... I'd been trying for several days to work it out, and it just clicked!

Apologies for another OT post, but I know we have a few Java buffs here

I'm writing a somewhat pointless fraction calculation class for Uni... but I'm experiencing a problem. I've defined my own exception for the class (FractionException - only the one, as I've overloaded some methods to eliminate most of the problems), but I'm a little stumped.

The class is called Fraction and it simply does addition, subtraction, multiplication and division of fractions. In the constructor I'm checking the format of the input string (in the String format "X/Y" where X and Y are integers), and throwing an exception if it's invalid.

However, this is where I hit my problem. In my add/sub/mul/div methods, I'm instantiating a new Fraction object to return to the user (so I don't change the current and input fractions)... but obviously, if I try to catch this exception, it errors on return (variable undefined), and if I try to catch the return, too, it errors on that (no return specified).

I'm a little stumped, and I've searched high and low, but to no avail. I'm sure I'm missing something blindingly obvious, but hey...

Thanks in advance folks
-
(JamesF1) DELETED by JamesF1 : Not needed

FGED GREDG RDFGDR GSFDG