Java Throw Exception

Started by
1 comment, last by Cornstalks 11 years, 7 months ago
Hello,
I have an application which excepts a username and password input from the user. Then attempts a network connection, 3 classes deep from my form events (the view). So deep in my networking connection I want to throw and Exception and log some text for the user to see. So..

with in this method I have something like..

public boolean doAConnect() throws Exception
{
//check invalid usernamepassword here...
if (errorCode == invalidUsernamePass)
throw new Exception("Invalid Username and Password);



the problem is that in my view when I use the try/catch, I am getting a "Java.lang.exception error: <error message here>". I only want the error message I set! Any ideas how I can just show the message to the user without the "Java.lang.Exception error:" pre-pended onto my string?

try{
doAConnect()
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
Advertisement
Did you try the getMessage() method instead of toString()?
Exception.getMessage()

edit: WTF... it's impossible to beat SiCrane...
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement