Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Override Exception parameters

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need an extra exception parameter in my catch clauses. I need something like :


I just need it to catch the exception and be able to hold a local value from the try statement.
I guess my question is, would I have to override the method and write everything out myself? Could you give me an example?

Thanks,
John Price
 
Marshal
Posts: 67413
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Move the variable outside the try block so that it is in scope in the catch block.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll show you exactly what I'm up against :


That is my current code. In the catch statement, I want to do this :


Basically, I need to have the remote socket address for the specific client passed through to the catch clause. The reason is to get rid of their name from the "Online User List", which is "ipVSname". It is a hashmap, in case you are wondering.

Thanks,
John Price

EDITS : Fixed some variable names.
 
Sheriff
Posts: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As said, move the variable declaration outside the try statement:
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was actually easier than what we both said. The actual exception part (that threw an exception when someone disconnected, etc) was in the thread. I could just make a variable anywhere in that. I have yet to test this with multiple users, but I have a strong sensing that it will work.

Thank you so much,
John Price
    Bookmark Topic Watch Topic
  • New Topic