Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Java Throw Exception

4: Adsense

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   

150
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.


#2 SiCrane   Moderators   

11764
Like
0Likes
Like

Posted 21 September 2012 - 09:39 AM

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

#3 Cornstalks   Members   

7030
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.