Sign in to follow this  
Instigator

Java Throw Exception

Recommended Posts

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..
[CODE]
public boolean doAConnect() [b]throws Exception[/b]
{
//check invalid usernamepassword here...
if (errorCode == invalidUsernamePass)
throw new Exception("Invalid Username and Password);
[/CODE]


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?
[CODE]
try{
doAConnect()
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
[/CODE] Edited by Instigator

Share this post


Link to post
Share on other sites
[url="http://docs.oracle.com/javase/6/docs/api/java/lang/Throwable.html#getMessage()"]Exception.getMessage()[/url]

[b]edit:[/b] WTF... it's impossible to beat SiCrane... Edited by Cornstalks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this