Jump to content

  • Log In with Google      Sign In   
  • Create Account


Java Throw Exception


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Instigator   Members   -  Reputation: 149

Like
0Likes
Like

Posted 21 September 2012 - 09:36 AM

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() [b]throws Exception[/b]
{
//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());
}

Edited by Instigator, 21 September 2012 - 09:41 AM.


Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9395

Like
0Likes
Like

Posted 21 September 2012 - 09:39 AM

Did you try the getMessage() method instead of toString()?

#3 Cornstalks   Crossbones+   -  Reputation: 6966

Like
0Likes
Like

Posted 21 September 2012 - 09:39 AM

Exception.getMessage()

edit: WTF... it's impossible to beat SiCrane...

Edited by Cornstalks, 21 September 2012 - 09:40 AM.

[ 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 ]




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS