- A triangle should not have any sides of length 0. If it does, it’s either a line segment or a point, depending on how many sides are 0.
- Negative length doesn’t make sense.
- Any two sides of a triangle should add up to more than the third side.
- See 3, and focus on the “more”.
You shouldn’t need to change the TriangleError code, AFAICS. Looks like your syntax is just a little wacky. Try changing
raise new.TriangleError
to
raise TriangleError, "why the exception happened"
Also, you should be testing the values (and throwing exceptions) before you do anything with them. Move the exception stuff to the beginning of the function.